lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <face8e0a-b3f6-85d9-ce1d-8afecdafe2a8@linux.dev>
Date: Fri, 4 Aug 2023 21:53:12 +0100
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: Li Zetao <lizetao1@...wei.com>, saeedm@...dia.com, leon@...nel.org,
 davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org
Cc: pabeni@...hat.com, shayd@...dia.com, roid@...dia.com, mbloch@...dia.com,
 vladbu@...dia.com, elic@...dia.com, netdev@...r.kernel.org,
 linux-rdma@...r.kernel.org
Subject: Re: [PATCH net-next] net/mlx5: Devcom, only use devcom after NULL
 check in mlx5_devcom_send_event()

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@...el.com>
> Reported-by: Dan Carpenter <error27@...il.com>
> Closes: https://lore.kernel.org/r/202308041028.AkXYDwJ6-lkp@intel.com/
> Signed-off-by: Li Zetao <lizetao1@...wei.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));


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ