mlx5: Restore err assignment in mlx5_mdev_init
Subsystems (4)
PATCH 1/1 mlx5: Restore err assignment in mlx5_mdev_init
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;
^
= 01 warning generated.
This path previously returned -ENOMEM, restore that error code so that it is not uninitialized.
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -0
@@ -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
Signature · 1 line
2.27.0.rc0
Quoted 37 lines · 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; ^ = 01 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")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1281
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +1
-0@@ -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.
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0}base-commit:
c0cc73b79123e67b212bd537a7af88e52c9fbeac--
2.27.0.rc0
Quoted 44 lines · Leon Romanovsky
Quoted 37 lines · 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; ^ = 01 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")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1281
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +1
-0@@ -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.
Quoted 1 line
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").
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0}base-commit:
c0cc73b79123e67b212bd537a7af88e52c9fbeac--
2.27.0.rc0
Quoted 47 lines · Nathan Chancellor
Quoted 44 lines · Leon Romanovsky
Quoted 37 lines · 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; ^ = 01 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")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1281
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +1
-0@@ -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.Quoted 1 line
Failure to create debugfs should never fail the driver.
Quoted 3 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0}base-commit:
c0cc73b79123e67b212bd537a7af88e52c9fbeac--
2.27.0.rc0