From patchwork Mon Sep 18 12:34:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cai Huoqing X-Patchwork-Id: 141470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2786703vqi; Mon, 18 Sep 2023 09:27:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXiYpqjmrMXw6tLn9CNEO5BSf0IIybjungDIOSL90wexhF8tUUc+FMXie28AaN8RbTJYh+ X-Received: by 2002:a05:6a00:2313:b0:68a:6926:78ac with SMTP id h19-20020a056a00231300b0068a692678acmr9442939pfh.22.1695054455846; Mon, 18 Sep 2023 09:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695054455; cv=none; d=google.com; s=arc-20160816; b=hcdRI25qdS5mBHxUKPNLPbXt1ugQVAUMa+OxXKbHW+lFVrnORcDP4dUBIuAsvIzM+O U+gAk4aU1IPJEUv3PylX83jhMpVFJGODyeTWqYaIp1Y+sr9BOSTsctuSYVZn4oFA104P xJPxMf/qI2AgyM2x3V+3Daz0xVJJr9LBRlrInmb3Y8hGk9yyhyKzxU2e1D4NHHZWcv0S eNNVDkHlxLIwnl4CqO+8xLmUdzsMoxPKzJyU2OlroZFP+iIDOyE4VR/3v/1YKrxbUnKB g4eviY/89EeLalbdHz0K7fA7MCcxS/r67Udzj34NrufPeWn4LNErOvIS+OgmNB41Q3bZ mG8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tzdxyJL0ghA962IZMjb5yhiDtQvWieedpUo2tK/XcEU=; fh=gyOEcM1qWxhvlYkaDF1qjrFd1CkRDMzHKjVeIhrrSSs=; b=KrXSaFimtm/ljNgvDO0nIXHoorCmMV36k/f8cYYdeRmdilpDKNRM51/RdahR0SPzs2 3cDt2Dp148UbaZ9EDjdn1BjO9uXbZ6iLxJ14UPORynP4rnJgT9NUl6W5ZH0RvaAYXnbd 1NJy211qWTlk1PNNam9WzPHEyBM6yGe90jc6R9JZ6nVlvR5YxhlPk7+Bn694lzADV4Uh u+uUEg3Fx7t+D3fW+yBIroAYKq6vBBWVaDurVZRO7biT45oKKorHxPKW6F9DwXUt9K9y gD0Q+512uR1L4fsAOvPDY4dyQVu/jSJuGtYPJlY/SxpTXVi94DwTKFlCdQ+yFzOAVXwS LyHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nQ7NV2ah; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bd6-20020a056a00278600b0068e3fe64a03si8208361pfb.308.2023.09.18.09.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:27:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nQ7NV2ah; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3B63281FD9D7; Mon, 18 Sep 2023 05:44:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241327AbjIRMnf (ORCPT + 27 others); Mon, 18 Sep 2023 08:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241523AbjIRMnF (ORCPT ); Mon, 18 Sep 2023 08:43:05 -0400 X-Greylist: delayed 502 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 18 Sep 2023 05:42:32 PDT Received: from out-210.mta1.migadu.com (out-210.mta1.migadu.com [IPv6:2001:41d0:203:375::d2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091E910F for ; Mon, 18 Sep 2023 05:42:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1695040445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tzdxyJL0ghA962IZMjb5yhiDtQvWieedpUo2tK/XcEU=; b=nQ7NV2ahM6CIzA3I5Z+4WcikmpCuETB9Mx5x/LMHaYRKce4ilfhUEjnANu0TqvP8hZJWsj ik8rjMj3RNb7UTDrOPwRIHxIEegG0dqomII6W85MT07xaGZVNRBoXYvdCIyFYvMjrFfrPa rJg+BPFJNnQfXJNN+oP4P4mO4P0VAq0= From: Cai Huoqing To: cai.huoqing@linux.dev Cc: Dan Carpenter , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' Date: Mon, 18 Sep 2023 20:34:01 +0800 Message-Id: <20230918123401.6951-1-cai.huoqing@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 05:44:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777393421491923848 X-GMAIL-MSGID: 1777393421491923848 Fix warning, 'hwdev' is checked too late Fixes: 2acf960e3be6 ("net: hinic: Add support for configuration of rx-vlan-filter by ethtool") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202309112354.pikZCmyk-lkp@intel.com/ Signed-off-by: Cai Huoqing --- drivers/net/ethernet/huawei/hinic/hinic_port.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c index 9406237c461e..bf920c709f82 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_port.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c @@ -450,8 +450,8 @@ int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en) int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en) { struct hinic_hwdev *hwdev = nic_dev->hwdev; - struct hinic_hwif *hwif = hwdev->hwif; - struct pci_dev *pdev = hwif->pdev; + struct hinic_hwif *hwif; + struct pci_dev *pdev; struct hinic_vlan_filter vlan_filter; u16 out_size = sizeof(vlan_filter); int err; @@ -459,6 +459,9 @@ int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en) if (!hwdev) return -EINVAL; + hwif = hwdev->hwif; + pdev = hwif->pdev; + vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif); vlan_filter.enable = en;