Skip to contentSkip to conversation

ath5k: Fix debugfs_create_dir error checking

PATCH In review Atul Raut 2 participants 2 messages Jul 31, 2023 Atheros ATH5K wireless driver

lore
Share & tools
lore

Atul Raut

author
#0 lore raw

PATCH 1/1 ath5k: Fix debugfs_create_dir error checking

The debugfs_create_dir function returns ERR_PTR in case of error and the correct way to check an error is 'IS_ERR' inline function.
This patch will replace the null-comparison with IS_ERR

This issue was found with the help of Coccinelle. ./drivers/net/wireless/ath/ath5k/debug.c:985:6-12: Wrong debugfs call error processing on line 985

---
 drivers/net/wireless/ath/ath5k/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/debug.c +1 -1
index 4b41160e5d38..08058b3f7e22 100644
@@ -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 · 6 lines
2.34.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
maintainer
#1 lore raw
Quoted 18 lines · Atul Raut

The debugfs_create_dir function returns ERR_PTR in case of error and the correct way to check an error is 'IS_ERR' inline function.
This patch will replace the null-comparison with IS_ERR

This issue was found with the help of Coccinelle. ./drivers/net/wireless/ath/ath5k/debug.c:985:6-12: Wrong debugfs call error processing on line 985

---
  drivers/net/wireless/ath/ath5k/debug.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/debug.c +0 -0
index 4b41160e5d38..08058b3f7e22 100644

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))

Already fixed by:
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

Signature · 2 lines
js
suse labs