net/mlx5: Don't fail driver on failure to create debugfs
Subsystems (4)
PATCH 1/1 net/mlx5: Don't fail driver on failure to create debugfs
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of debugfs_create_dir() is wrong because by the design debugfs failures should never fail the driver and the check itself was wrong too. The kernel compiled without CONFIG_DEBUG_FS will return ERR_PTR(-ENODEV) and not NULL as expected.
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +0 -5
@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -if (!priv->dbg_root) { -dev_err (dev->device,"mlx5_core: error, Cannot create debugfs dir, aborting\n" ); - goto err_dbg_root; - } - err =mlx5_health_init (dev);if (err) goto err_health_init;
--
2.26.2
Quoted 29 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of
debugfs_create_dir()is wrong because by the design debugfs failures should never fail the driver and the check itself was wrong too. The kernel compiled withoutCONFIG_DEBUG_FSwill returnERR_PTR(-ENODEV)and not NULL as expected.
Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
Thanks! That's what I figured it should be.
Quoted 26 lines
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-6@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -if (!priv->dbg_root) { -dev_err (dev->device,"mlx5_core: error, Cannot create debugfs dir, aborting\n" ); - goto err_dbg_root; - } - err =mlx5_health_init (dev);if (err) goto err_health_init; --2.26.2
Quoted 52 lines · Nathan Chancellor
Quoted 29 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of
debugfs_create_dir()is wrong because by the design debugfs failures should never fail the driver and the check itself was wrong too. The kernel compiled withoutCONFIG_DEBUG_FSwill returnERR_PTR(-ENODEV)and not NULL as expected.Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Thanks! That's what I figured it should be.
Reviewed-by Nathan Chancellor <[email protected]>Quoted 13 lines
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1280
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-3priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -if (!priv->dbg_root) { -dev_err (dev->device,"mlx5_core: error, Cannot create debugfs dir, aborting\n" ); - goto err_dbg_root;
Actually, this removes the only use of err_dbg_root, so that should be removed at the same time.
Cheers,
Nathan
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-3- } - err =mlx5_health_init (dev);if (err) goto err_health_init; --2.26.2
Quoted 61 lines · Nathan Chancellor
Quoted 60 lines · Nathan Chancellor
Quoted 35 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of
debugfs_create_dir()is wrong because
by the design debugfs failures should never fail the driver and the
check itself was wrong too. The kernel compiled withoutCONFIG_DEBUG_FS
will returnERR_PTR(-ENODEV)and not NULL as expected.Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Thanks! That's what I figured it should be.
Reviewed-by Nathan Chancellor <[email protected]>Quoted 15 lines
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
Quoted 11 lines
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1280
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-3priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -if (!priv->dbg_root) { - dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n"); - goto err_dbg_root;Actually, this removes the only use of
err_dbg_root, so that should be
removed at the same time.
Fixed this up and applied to net-next-mlx5,
Thanks!
Quoted 74 lines · Saeed Mahameed
Quoted 61 lines · Nathan Chancellor
Quoted 60 lines · Nathan Chancellor
Quoted 35 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of
debugfs_create_dir()is wrong because
by the design debugfs failures should never fail the driver and the
check itself was wrong too. The kernel compiled withoutCONFIG_DEBUG_FS
will returnERR_PTR(-ENODEV)and not NULL as expected.Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Thanks! That's what I figured it should be.
Reviewed-by Nathan Chancellor <[email protected]>Quoted 15 lines
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)Quoted 11 lines
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1280
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-3priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -if (!priv->dbg_root) { - dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n"); - goto err_dbg_root;Actually, this removes the only use of
err_dbg_root, so that should be
removed at the same time.
Quoted 3 lines
Fixed this up and applied to net-next-mlx5,
Thanks!
Hi Saeed,
I see this warning in mainline now, is this something you were planning to have merged this cycle or next? I see it in several configs so it would be nice if it could be resolved this one, since it was introduced by a patch in this cycle even though the core issue has been around for a few months.
Cheers,
Nathan
Quoted 89 lines · Nathan Chancellor
Quoted 82 lines · Saeed Mahameed
Quoted 68 lines · Nathan Chancellor
Quoted 66 lines · Nathan Chancellor
Quoted 37 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
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.
The check of returned value of
debugfs_create_dir()is wrong because
by the design debugfs failures should never fail the driver and
the
check itself was wrong too. The kernel compiled withoutCONFIG_DEBUG_FS
will returnERR_PTR(-ENODEV)and not NULL as expected.Quoted 5 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pciinit")
Reported-by Nathan Chancellor <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Thanks! That's what I figured it should be.
Reviewed-by Nathan Chancellor <[email protected]>Quoted 17 lines
---
Original discussion:
https://lore.kernel.org/lkml/[email protected]--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-0@@ -1275,11 +1275,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) priv->dbg_root = debugfs_create_dir(dev_name(dev- >device),Quoted 12 lines
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) · line 1280
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-2mlx5_debugfs_root); -if (!priv->dbg_root) { - dev_err(dev->device, "mlx5_core: error, Cannotcreate
debugfs dir, aborting\n");drivers/net/ethernet/mellanox/mlx5/core/main.c +0
-1- goto err_dbg_root;Actually, this removes the only use of
err_dbg_root, so that should
be
removed at the same time.Quoted 3 lines
Fixed this up and applied to net-next-mlx5,
Thanks!Hi Saeed,
Quoted 9 lines
I see this warning in mainline now, is this something you were planning
to have merged this cycle or next? I see it in several configs so it would be nice if it could be resolved this one, since it was introduced
by a patch in this cycle even though the core issue has been around for
a few months.
Hi Nathan,
I just pulled this patch into net-mlx5, and will send it out in my net PR today.
Thanks,
Saeed.
Quoted 2 lines
Cheers,
Nathan
David Miller
maintainerSaeed, please pick this up.