Skip to content

Commit 17e73d4

Browse files
Leon RomanovskySaeed Mahameed
authored andcommitted
net/mlx5: Don't fail driver on failure to create debugfs
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: 11f3b84 ("net/mlx5: Split mdev init and pci init") Link: ClangBuiltLinux#1042 Reported-by: Nathan Chancellor <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 0d156f2 commit 17e73d4

File tree

1 file changed

+0
-6
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+0
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,11 +1281,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
12811281

12821282
priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
12831283
mlx5_debugfs_root);
1284-
if (!priv->dbg_root) {
1285-
dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
1286-
goto err_dbg_root;
1287-
}
1288-
12891284
err = mlx5_health_init(dev);
12901285
if (err)
12911286
goto err_health_init;
@@ -1300,7 +1295,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
13001295
mlx5_health_cleanup(dev);
13011296
err_health_init:
13021297
debugfs_remove(dev->priv.dbg_root);
1303-
err_dbg_root:
13041298
mutex_destroy(&priv->pgdir_mutex);
13051299
mutex_destroy(&priv->alloc_mutex);
13061300
mutex_destroy(&priv->bfregs.wc_head.lock);

0 commit comments

Comments
 (0)