[v2] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev'
Message ID | 20230919022715.6424-1-cai.huoqing@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3127622vqi; Mon, 18 Sep 2023 21:35:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUruyz4LCkQ5y07/WNSrlPvxZLGBnY8km0ON/e6WmE2wvenKlSInQN4EB4Sz9BE4Bw4cam X-Received: by 2002:a17:902:d904:b0:1c4:6613:82a3 with SMTP id c4-20020a170902d90400b001c4661382a3mr5317071plz.16.1695098141430; Mon, 18 Sep 2023 21:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695098141; cv=none; d=google.com; s=arc-20160816; b=FrBOz3NEovgdWga6/OTFVNjPCMgMbH+9d1wm439v5d/U6TckeC8aHgFhyzHHBkGk/4 Pv19CZAbvjD2Of5C+GKt3VsvDbAS6AXWj7X4/9v0EY5fCyF2DbBI9ueOH0ARvn1azB8h 8ZsL025jj5K9aii9yv9mOfP09x+q4g/LGUx7bqTdkg7PZRmgE8BpfVOzZn8bsnZFBsIN QjFQPqShhLDrJ7K/JlrTQTtM1zlV0+bFAiXZMHWl82TTHs0FBO1GJFUqHWncSLVDWMir BMsKdhZM77oQlZthGZuE9h9CHh1ttHGLSArggG6Df6I9vIdsFUXiVj8hh4rr83EJnXfJ /IyQ== 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=GldjsjLN9+yIG261E0aNo5eTT0aAfea0jQrrQue5u00=; fh=jzvFrJTsTYLTbY5Q0PLzwt78xItTBgctfW+b1rkE0Cs=; b=i9qNSAam3GCFSsGE68kBVd6NgeDj7OCfyu1574FWgcrNydYZ0pA+S8PC5JmdHsZS8w +PnJhTPKGazeq6H/vOFjMV7rGoz6OBenT70kDhQd5ze6F/7FeEK4F6sbrAIaG0+iovF7 /+eGDBOPTKC7KipCVLowaW4ZzYc03EhFokrLQEKoGUpE1z2o7aVb/3dQvYPpTubLMEx7 Cjws3oxBfbIgMN+pfwXSquRm6MzRxMsRRog088sNMsTHNC/bAMbD4N08Er1PUppFMkRi yFTl+qwKbBb4cPyPBCnsRjjbRFLjaG0dlIfczIcV+lhdFbONZbwwpUIoZ13d5EN9oW49 qr5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mkZMkq7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ld5-20020a170902fac500b001bbdb34628bsi8799322plb.289.2023.09.18.21.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 21:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mkZMkq7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id B00BC8027DD4; Mon, 18 Sep 2023 19:27:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbjISC12 (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Mon, 18 Sep 2023 22:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjISC12 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 22:27:28 -0400 Received: from out-212.mta1.migadu.com (out-212.mta1.migadu.com [IPv6:2001:41d0:203:375::d4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8F410A for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 19:27:21 -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=1695090440; 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=GldjsjLN9+yIG261E0aNo5eTT0aAfea0jQrrQue5u00=; b=mkZMkq7B3bUpxEPYmu2MMcafJg4hXDsOyrfwPXWWPuo23kQP5p5h2a7nbOPpddUEXUDmhf 3/dEV+SIuCGVpJMz0JvI/8VFF/lfB5lkXgdH/kllhkpg9ctUeoKO0voCtwe8OJ0D4beMvl QehRcZutZVMEFLVcDtA8HLkEmZ4GjXA= From: Cai Huoqing <cai.huoqing@linux.dev> To: vadim.fedorenko@linux.dev Cc: Cai Huoqing <cai.huoqing@linux.dev>, Dan Carpenter <dan.carpenter@linaro.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' Date: Tue, 19 Sep 2023 10:27:15 +0800 Message-Id: <20230919022715.6424-1-cai.huoqing@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 19:27:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777439228865401494 X-GMAIL-MSGID: 1777439228865401494 |
Series |
[v2] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev'
|
|
Commit Message
Cai Huoqing
Sept. 19, 2023, 2:27 a.m. UTC
'hwdev' is checked too late and hwdev will not be NULL, so remove the check
Fixes: 2acf960e3be6 ("net: hinic: Add support for configuration of rx-vlan-filter by ethtool")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202309112354.pikZCmyk-lkp@intel.com/
Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
---
v1->v2: Remove 'hwdev' check directly
v1 link: https://lore.kernel.org/lkml/20230918123401.6951-1-cai.huoqing@linux.dev/
drivers/net/ethernet/huawei/hinic/hinic_port.c | 3 ---
1 file changed, 3 deletions(-)
Comments
On 19/09/2023 03:27, Cai Huoqing wrote: > 'hwdev' is checked too late and hwdev will not be NULL, so remove the check > > Fixes: 2acf960e3be6 ("net: hinic: Add support for configuration of rx-vlan-filter by ethtool") > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lore.kernel.org/r/202309112354.pikZCmyk-lkp@intel.com/ > Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev> > --- > v1->v2: Remove 'hwdev' check directly > v1 link: https://lore.kernel.org/lkml/20230918123401.6951-1-cai.huoqing@linux.dev/ > > drivers/net/ethernet/huawei/hinic/hinic_port.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c > index 9406237c461e..f81a43d2cdfc 100644 > --- a/drivers/net/ethernet/huawei/hinic/hinic_port.c > +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c > @@ -456,9 +456,6 @@ int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en) > u16 out_size = sizeof(vlan_filter); > int err; > > - if (!hwdev) > - return -EINVAL; > - > vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif); > vlan_filter.enable = en; > Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Tue, 19 Sep 2023 10:27:15 +0800 you wrote: > 'hwdev' is checked too late and hwdev will not be NULL, so remove the check > > Fixes: 2acf960e3be6 ("net: hinic: Add support for configuration of rx-vlan-filter by ethtool") > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lore.kernel.org/r/202309112354.pikZCmyk-lkp@intel.com/ > Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev> > > [...] Here is the summary with links: - [v2] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' https://git.kernel.org/netdev/net/c/22b6e7f3d6d5 You are awesome, thank you!
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c index 9406237c461e..f81a43d2cdfc 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_port.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c @@ -456,9 +456,6 @@ int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en) u16 out_size = sizeof(vlan_filter); int err; - if (!hwdev) - return -EINVAL; - vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif); vlan_filter.enable = en;