All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Li Zetao <lizetao1@huawei.com>,
	saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org
Cc: pabeni@redhat.com, shayd@nvidia.com, roid@nvidia.com,
	mbloch@nvidia.com, vladbu@nvidia.com, elic@nvidia.com,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next] net/mlx5: Devcom, only use devcom after NULL check in mlx5_devcom_send_event()
Date: Fri, 4 Aug 2023 21:53:12 +0100	[thread overview]
Message-ID: <face8e0a-b3f6-85d9-ce1d-8afecdafe2a8@linux.dev> (raw)
In-Reply-To: <20230804092636.91357-1-lizetao1@huawei.com>

On 04/08/2023 10:26, Li Zetao wrote:
> There is a warning reported by kernel test robot:
> 
> smatch warnings:
> drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c:264
>      mlx5_devcom_send_event() warn: variable dereferenced before
> 	IS_ERR check devcom (see line 259)
> 
> The reason for the warning is that the pointer is used before check, put
> the assignment to comp after devcom check to silence the warning.
> 
> Fixes: 88d162b47981 ("net/mlx5: Devcom, Infrastructure changes")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Closes: https://lore.kernel.org/r/202308041028.AkXYDwJ6-lkp@intel.com/
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> index feb62d952643..2bc18274858c 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> @@ -256,7 +256,7 @@ int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
>   			   int event, int rollback_event,
>   			   void *event_data)
>   {
> -	struct mlx5_devcom_comp *comp = devcom->comp;
> +	struct mlx5_devcom_comp *comp;
>   	struct mlx5_devcom_comp_dev *pos;

The code should end up with reverse x-mas tree order.
The change itself LGTM.

>   	int err = 0;
>   	void *data;
> @@ -264,6 +264,7 @@ int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
>   	if (IS_ERR_OR_NULL(devcom))
>   		return -ENODEV;
>   
> +	comp = devcom->comp;
>   	down_write(&comp->sem);
>   	list_for_each_entry(pos, &comp->comp_dev_list_head, list) {
>   		data = rcu_dereference_protected(pos->data, lockdep_is_held(&comp->sem));


  reply	other threads:[~2023-08-04 21:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  9:26 [PATCH net-next] net/mlx5: Devcom, only use devcom after NULL check in mlx5_devcom_send_event() Li Zetao
2023-08-04 20:53 ` Vadim Fedorenko [this message]
2023-08-13  8:02   ` Roi Dayan
2023-08-14  7:23   ` [PATCH -next v2] " Li Zetao
2023-08-14 10:11     ` Leon Romanovsky

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=face8e0a-b3f6-85d9-ce1d-8afecdafe2a8@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=elic@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lizetao1@huawei.com \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=shayd@nvidia.com \
    --cc=vladbu@nvidia.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.