All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: kernel-janitors@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>
Subject: Re: [bug report] net/mlx5: SD, Implement devcom communication and primary election
Date: Sun, 17 Mar 2024 11:12:33 +0200	[thread overview]
Message-ID: <f09666c8-e604-41f6-958b-4cc55c73faf9@gmail.com> (raw)
In-Reply-To: <84c44ab9-46de-4380-9e24-c0841ed3db52@moroto.mountain>



On 15/03/2024 17:19, Dan Carpenter wrote:
> Hello Tariq Toukan,
> 
> Commit d3d057666090 ("net/mlx5: SD, Implement devcom communication
> and primary election") from Feb 14, 2024 (linux-next), leads to the
> following Smatch static checker warning:
> 
> 	drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c:221 sd_register()
> 	error: 'devcom' dereferencing possible ERR_PTR()
> 
> drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
>      206 static int sd_register(struct mlx5_core_dev *dev)
>      207 {
>      208         struct mlx5_devcom_comp_dev *devcom, *pos;
>      209         struct mlx5_core_dev *peer, *primary;
>      210         struct mlx5_sd *sd, *primary_sd;
>      211         int err, i;
>      212
>      213         sd = mlx5_get_sd(dev);
>      214         devcom = mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_SD_GROUP,
>      215                                                 sd->group_id, NULL, dev);
>      216         if (!devcom)
> 
> The mlx5_devcom_register_component() function returns a mix of error
> pointers and NULL.  It's not done really done correctly...  Here is an
> explanation of how that normally works:
> 
> https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
> 
> mlx5_devcom_register_component() is not optional so it should only
> return error pointers.
> 
>      217                 return -ENOMEM;
>      218
>      219         sd->devcom = devcom;
>      220
> --> 221         if (mlx5_devcom_comp_get_size(devcom) != sd->host_buses)
>                                                ^^^^^^
> Dead.
> 
>      222                 return 0;
> 
> regards,
> dan carpenter

Hi Dan,

Thanks for your report!
I prepared a fix and will submit it soon.

Regards,
Tariq

      reply	other threads:[~2024-03-17  9:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 15:19 [bug report] net/mlx5: SD, Implement devcom communication and primary election Dan Carpenter
2024-03-17  9:12 ` Tariq Toukan [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=f09666c8-e604-41f6-958b-4cc55c73faf9@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=tariqt@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.