drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
Subsystems (2)
PATCH 1/1 drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
Make IS_ERR() judge the debugfs_create_dir() function return in ath5k_debug_init_device().
--- drivers/net/wireless/ath/ath5k/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/debug.c +1 -1
@@ -982,7 +982,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah) ah->debug.level = ath5k_debug; phydir =debugfs_create_dir ("ath5k" , ah->hw->wiphy->debugfsdir); -if (!phydir) +if (IS_ERR (phydir))return ;debugfs_create_file ("debug" ,0600 , phydir, ah, &fops_debug);
Signature · 1 line
2.39.0
Quoted 13 lines · Minjie Du
Make
IS_ERR()judge thedebugfs_create_dir()function return inath5k_debug_init_device().Signed-off-by Minjie Du <[email protected]>--- drivers/net/wireless/ath/ath5k/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath5k/debug.c +0
-0
drivers/net/wireless/ath/ath5k/debug.c ath5k_debug_init_device(struct ath5k_hw *ah) · line 985
Quoted 5 lines
drivers/net/wireless/ath/ath5k/debug.c +1
-1@@ -982,7 +982,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah) ah->debug.level = ath5k_debug; phydir =debugfs_create_dir ("ath5k" , ah->hw->wiphy->debugfsdir); -if (!phydir) +if (IS_ERR (phydir))
Please use IS_ERR_OR_NULL() instead.
With that change added:
Luis
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jiri Slaby
maintainerQuoted 6 lines · Markus Elfring
Quoted 6 lines
Quoted 5 lines
+++
b/drivers/net/wireless/ath/ath5k/debug.cdrivers/net/wireless/ath/ath5k/debug.c +0
-0@@ -982,7 +982,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah) ah->debug.level = ath5k_debug; phydir =debugfs_create_dir ("ath5k" , ah->hw->wiphy->debugfsdir);drivers/net/wireless/ath/ath5k/debug.c +0
-1-if (!phydir)
Quoted 7 lines
Quoted 3 lines
drivers/net/wireless/ath/ath5k/debug.c ath5k_debug_init_device(struct ath5k_hw *ah) · line 985
Quoted 1 line
drivers/net/wireless/ath/ath5k/debug.c +1
-0+if (IS_ERR (phydir))Please use
IS_ERR_OR_NULL()instead.I find your support for consistent error detection interesting here. Contributors for other Linux software components provide different development views.
IS_ERR_OR_NULL() is almost never correct. It is used exceptionally in cases where one needs to distinct three states. It's not the case for sysfs/debugfs interfaces.
Quoted 2 lines
Would a subject like “[PATCH v2] ath5k: Fix an error check in ath5k_debug_init_device()” be more appropriate?
Yes (pointing out specifically "()" at the end). And add the "why" part to the message log too, please.
thanks,
Signature · 2 lines
js suse labs
Quoted 10 lines · Jiri Slaby
Quoted 9 lines · Markus Elfring
Quoted 9 lines
Quoted 5 lines
+++
b/drivers/net/wireless/ath/ath5k/debug.cdrivers/net/wireless/ath/ath5k/debug.c +0
-0@@ -982,7 +982,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah) ah->debug.level = ath5k_debug; phydir =debugfs_create_dir ("ath5k" , ah->hw->wiphy->debugfsdir);drivers/net/wireless/ath/ath5k/debug.c +0
-1-if (!phydir)drivers/net/wireless/ath/ath5k/debug.c ath5k_debug_init_device(struct ath5k_hw *ah) · line 985
Quoted 1 line
drivers/net/wireless/ath/ath5k/debug.c +1
-0+if (IS_ERR (phydir))Please use
IS_ERR_OR_NULL()instead.
The correct thing for debugfs is to delete the error handling entirely. Checking for NULL is harmless but checking for IS_ERR() will break the driver if debugfs is turned off.
Debugfs is a special case where the error handling was deliberately written so that it's basically impossible to do it correctly. Because as I said at the start, the correct thing is to delete it.
regards,
dan carpenter
subject prefix should be "wifi: ath5k: "
Quoted 21 lines · Minjie Du
Make
IS_ERR()judge thedebugfs_create_dir()function return inath5k_debug_init_device().Signed-off-by Minjie Du <[email protected]>--- drivers/net/wireless/ath/ath5k/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath5k/debug.c +1
-1@@ -982,7 +982,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah) ah->debug.level = ath5k_debug; phydir =debugfs_create_dir ("ath5k" , ah->hw->wiphy->debugfsdir); -if (!phydir) +if (IS_ERR (phydir))return ;debugfs_create_file ("debug" ,0600 , phydir, ah, &fops_debug);