All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Cai Huoqing <cai.huoqing@linux.dev>
Cc: 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: Re: [PATCH] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev'
Date: Mon, 18 Sep 2023 13:58:30 +0100	[thread overview]
Message-ID: <dfcf35c3-8208-48fc-5492-97dd3b1c83fb@linux.dev> (raw)
In-Reply-To: <20230918123401.6951-1-cai.huoqing@linux.dev>

On 18/09/2023 13:34, Cai Huoqing wrote:
> Fix warning, 'hwdev' is checked too late

I cannot find any spot where hwdev will be NULL. Other functions in the 
driver assume that hwdev points to proper structure always. I believe 
the proper fix will be to remove redundant 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>
> ---
>   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;
>   


      reply	other threads:[~2023-09-18 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 12:34 [PATCH] net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' Cai Huoqing
2023-09-18 12:58 ` Vadim Fedorenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dfcf35c3-8208-48fc-5492-97dd3b1c83fb@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=cai.huoqing@linux.dev \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.