All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init
@ 2020-05-30  5:54 Nathan Chancellor
  2020-05-31  9:58 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2020-05-30  5:54 UTC (permalink / raw)
  To: Saeed Mahameed, Leon Romanovsky
  Cc: David S. Miller, Jakub Kicinski, netdev, linux-rdma,
	Parav Pandit, linux-kernel, clang-built-linux, Nathan Chancellor

Clang warns:

drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:6: warning: variable
'err' is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
        if (!priv->dbg_root) {
            ^~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/main.c:1303:9: note:
uninitialized use occurs here
        return err;
               ^~~
drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:2: note: remove the
'if' if its condition is always false
        if (!priv->dbg_root) {
        ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/main.c:1259:9: note: initialize
the variable 'err' to silence this warning
        int err;
               ^
                = 0
1 warning generated.

This path previously returned -ENOMEM, restore that error code so that
it is not uninitialized.

Fixes: 810cbb25549b ("net/mlx5: Add missing mutex destroy")
Link: https://github.com/ClangBuiltLinux/linux/issues/1042
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index df46b1fce3a7..ac68445fde2d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1277,6 +1277,7 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 					    mlx5_debugfs_root);
 	if (!priv->dbg_root) {
 		dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
+		err = -ENOMEM;
 		goto err_dbg_root;
 	}
 

base-commit: c0cc73b79123e67b212bd537a7af88e52c9fbeac
-- 
2.27.0.rc0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init
  2020-05-30  5:54 [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init Nathan Chancellor
@ 2020-05-31  9:58 ` Leon Romanovsky
  2020-06-02  4:07   ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2020-05-31  9:58 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, Parav Pandit, linux-kernel, clang-built-linux

On Fri, May 29, 2020 at 10:54:48PM -0700, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:6: warning: variable
> 'err' is used uninitialized whenever 'if' condition is true
> [-Wsometimes-uninitialized]
>         if (!priv->dbg_root) {
>             ^~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/main.c:1303:9: note:
> uninitialized use occurs here
>         return err;
>                ^~~
> drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:2: note: remove the
> 'if' if its condition is always false
>         if (!priv->dbg_root) {
>         ^~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/main.c:1259:9: note: initialize
> the variable 'err' to silence this warning
>         int err;
>                ^
>                 = 0
> 1 warning generated.
>
> This path previously returned -ENOMEM, restore that error code so that
> it is not uninitialized.
>
> Fixes: 810cbb25549b ("net/mlx5: Add missing mutex destroy")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1042
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> index df46b1fce3a7..ac68445fde2d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> @@ -1277,6 +1277,7 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
>  					    mlx5_debugfs_root);
>  	if (!priv->dbg_root) {
>  		dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
> +		err = -ENOMEM;
>  		goto err_dbg_root;
                ^^^^^^^^^^^^^^^^^^ this is wrong.
Failure to create debugfs should never fail the driver.

>  	}
>
>
> base-commit: c0cc73b79123e67b212bd537a7af88e52c9fbeac
> --
> 2.27.0.rc0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init
  2020-05-31  9:58 ` Leon Romanovsky
@ 2020-06-02  4:07   ` Nathan Chancellor
  2020-06-02  7:07     ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2020-06-02  4:07 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, Parav Pandit, linux-kernel, clang-built-linux

On Sun, May 31, 2020 at 12:58:10PM +0300, Leon Romanovsky wrote:
> On Fri, May 29, 2020 at 10:54:48PM -0700, Nathan Chancellor wrote:
> > Clang warns:
> >
> > drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:6: warning: variable
> > 'err' is used uninitialized whenever 'if' condition is true
> > [-Wsometimes-uninitialized]
> >         if (!priv->dbg_root) {
> >             ^~~~~~~~~~~~~~~
> > drivers/net/ethernet/mellanox/mlx5/core/main.c:1303:9: note:
> > uninitialized use occurs here
> >         return err;
> >                ^~~
> > drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:2: note: remove the
> > 'if' if its condition is always false
> >         if (!priv->dbg_root) {
> >         ^~~~~~~~~~~~~~~~~~~~~~
> > drivers/net/ethernet/mellanox/mlx5/core/main.c:1259:9: note: initialize
> > the variable 'err' to silence this warning
> >         int err;
> >                ^
> >                 = 0
> > 1 warning generated.
> >
> > This path previously returned -ENOMEM, restore that error code so that
> > it is not uninitialized.
> >
> > Fixes: 810cbb25549b ("net/mlx5: Add missing mutex destroy")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1042
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > index df46b1fce3a7..ac68445fde2d 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > @@ -1277,6 +1277,7 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
> >  					    mlx5_debugfs_root);
> >  	if (!priv->dbg_root) {
> >  		dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
> > +		err = -ENOMEM;
> >  		goto err_dbg_root;
>                 ^^^^^^^^^^^^^^^^^^ this is wrong.
> Failure to create debugfs should never fail the driver.

Fair enough, could you guys deal with this then to make sure it gets
fixed properly? It appears to be introduced in 11f3b84d7068 ("net/mlx5:
Split mdev init and pci init").

> >  	}
> >
> >
> > base-commit: c0cc73b79123e67b212bd537a7af88e52c9fbeac
> > --
> > 2.27.0.rc0
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init
  2020-06-02  4:07   ` Nathan Chancellor
@ 2020-06-02  7:07     ` Leon Romanovsky
  0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-06-02  7:07 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, Parav Pandit, linux-kernel, clang-built-linux

On Mon, Jun 01, 2020 at 09:07:48PM -0700, Nathan Chancellor wrote:
> On Sun, May 31, 2020 at 12:58:10PM +0300, Leon Romanovsky wrote:
> > On Fri, May 29, 2020 at 10:54:48PM -0700, Nathan Chancellor wrote:
> > > Clang warns:
> > >
> > > drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:6: warning: variable
> > > 'err' is used uninitialized whenever 'if' condition is true
> > > [-Wsometimes-uninitialized]
> > >         if (!priv->dbg_root) {
> > >             ^~~~~~~~~~~~~~~
> > > drivers/net/ethernet/mellanox/mlx5/core/main.c:1303:9: note:
> > > uninitialized use occurs here
> > >         return err;
> > >                ^~~
> > > drivers/net/ethernet/mellanox/mlx5/core/main.c:1278:2: note: remove the
> > > 'if' if its condition is always false
> > >         if (!priv->dbg_root) {
> > >         ^~~~~~~~~~~~~~~~~~~~~~
> > > drivers/net/ethernet/mellanox/mlx5/core/main.c:1259:9: note: initialize
> > > the variable 'err' to silence this warning
> > >         int err;
> > >                ^
> > >                 = 0
> > > 1 warning generated.
> > >
> > > This path previously returned -ENOMEM, restore that error code so that
> > > it is not uninitialized.
> > >
> > > Fixes: 810cbb25549b ("net/mlx5: Add missing mutex destroy")
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/1042
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > >  drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > > index df46b1fce3a7..ac68445fde2d 100644
> > > --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> > > @@ -1277,6 +1277,7 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
> > >  					    mlx5_debugfs_root);
> > >  	if (!priv->dbg_root) {
> > >  		dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
> > > +		err = -ENOMEM;
> > >  		goto err_dbg_root;
> >                 ^^^^^^^^^^^^^^^^^^ this is wrong.
> > Failure to create debugfs should never fail the driver.
>
> Fair enough, could you guys deal with this then to make sure it gets
> fixed properly? It appears to be introduced in 11f3b84d7068 ("net/mlx5:
> Split mdev init and pci init").

Thanks, I will send it today.

>
> > >  	}
> > >
> > >
> > > base-commit: c0cc73b79123e67b212bd537a7af88e52c9fbeac
> > > --
> > > 2.27.0.rc0
> > >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-02  7:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30  5:54 [PATCH net-next] mlx5: Restore err assignment in mlx5_mdev_init Nathan Chancellor
2020-05-31  9:58 ` Leon Romanovsky
2020-06-02  4:07   ` Nathan Chancellor
2020-06-02  7:07     ` Leon Romanovsky

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.