Skip to contentSkip to conversation

net/mlx5: Don't fail driver on failure to create debugfs

PATCH In review Leon Romanovsky 4 participants 7 messages Jun 2, 2020 – Jun 11, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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;
               ^
                = 0

1 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.

Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")

---
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
index df46b1fce3a7..110e8d277d15 100644
@@ -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

Reviewed-by on v1 1/1
#1 lore raw
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;
               ^
                = 0

1 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.

Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")

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
index df46b1fce3a7..110e8d277d15 100644
@@ -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

#2 lore raw
In reply to Nathan Chancellor
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;
               ^
                = 0

1 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.

Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")

Thanks! That's what I figured it should be.

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
index df46b1fce3a7..110e8d277d15 100644
@@ -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 -3
 	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;

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

#3 lore raw
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;
               ^
                = 0

1 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.

Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")

Thanks! That's what I figured it should be.

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
index df46b1fce3a7..110e8d277d15 100644
@@ -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 -3
 	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;

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!

#4 lore raw
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;
               ^
                = 0

1 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.

Quoted 4 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci init")

Thanks! That's what I figured it should be.

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
index df46b1fce3a7..110e8d277d15 100644
@@ -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 -3
 	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;

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

#5 lore raw
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;
               ^
                = 0

1 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.

Quoted 5 lines
Fixes 11f3b84d7068 ("net/mlx5: Split mdev init and pci

init")

Thanks! That's what I figured it should be.

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
index df46b1fce3a7..110e8d277d15 100644
@@ -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 -2
 					    mlx5_debugfs_root);
-	if (!priv->dbg_root) {
-		dev_err(dev->device, "mlx5_core: error, Cannot

create
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