ath11k: fix return value check in ath11k_spectral_debug_register()
PATCH 1/1 ath11k: fix return value check in ath11k_spectral_debug_register()
Fix the incorrect return value check for debugfs_create_file(), which returns ERR_PTR(-ERROR) instead of NULL when it fails.
--- drivers/net/wireless/ath/ath11k/spectral.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/spectral.c +3 -3
@@ -942,7 +942,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_ctl); -if (!ar->spectral.scan_ctl) { +if (IS_ERR (ar->spectral.scan_ctl)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;
@@ -953,7 +953,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_count); -if (!ar->spectral.scan_count) { +if (IS_ERR (ar->spectral.scan_count)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;
@@ -964,7 +964,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_bins); -if (!ar->spectral.scan_bins) { +if (IS_ERR (ar->spectral.scan_bins)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;
Signature · 1 line
2.34.1
Quoted 2 lines · Zhen Lei
Fix the incorrect return value check for
debugfs_create_file(), which returnsERR_PTR(-ERROR)instead of NULL when it fails.
Based upon the commit text this change is incorrect.
* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway.
So ath11k should not be checking the return value at all, and definitely should not be returning -EINVAL since the driver should still operate even if creating a debugfs file fails.
Quoted 38 lines
Fixes 9d11b7bff950 ("ath11k: add support for spectral scan")Signed-off-by Zhen Lei <[email protected]>--- drivers/net/wireless/ath/ath11k/spectral.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath11k/spectral.c +3
-3@@ -942,7 +942,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_ctl); -if (!ar->spectral.scan_ctl) { +if (IS_ERR (ar->spectral.scan_ctl)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;@@ -953,7 +953,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_count); -if (!ar->spectral.scan_count) { +if (IS_ERR (ar->spectral.scan_count)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;@@ -964,7 +964,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_bins); -if (!ar->spectral.scan_bins) { +if (IS_ERR (ar->spectral.scan_bins)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;
Quoted 6 lines · Jeff Johnson
Quoted 2 lines · Zhen Lei
Fix the incorrect return value check for
debugfs_create_file(), which returnsERR_PTR(-ERROR)instead of NULL when it fails.Based upon the commit text this change is incorrect.
Quoted 8 lines
* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway.So ath11k should not be checking the return value at all, and definitely should not be returning
-EINVALsince the driver should still operate even if creating a debugfs file fails.
OK, so that members such as scan_ctl in struct ath11k_spectral can be removed. I will update accordingly in v2.
Quoted 43 lines
Quoted 31 lines
Fixes 9d11b7bff950 ("ath11k: add support for spectral scan")Signed-off-by Zhen Lei <[email protected]>--- drivers/net/wireless/ath/ath11k/spectral.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath11k/spectral.c +2
-2@@ -942,7 +942,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_ctl); -if (!ar->spectral.scan_ctl) { +if (IS_ERR (ar->spectral.scan_ctl)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;@@ -953,7 +953,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_count); -if (!ar->spectral.scan_count) { +if (IS_ERR (ar->spectral.scan_count)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;drivers/net/wireless/ath/ath11k/spectral.c static inline int ath11k_spectral_debug_register(struct ath11k *ar) · line 970
Quoted 8 lines
drivers/net/wireless/ath/ath11k/spectral.c +1
-1@@ -964,7 +964,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_bins); -if (!ar->spectral.scan_bins) { +if (IS_ERR (ar->spectral.scan_bins)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;.
Signature · 2 lines
Regards, Zhen Lei
Quoted 14 lines · Leizhen (ThunderTown)
Quoted 11 lines · Jeff Johnson
Quoted 2 lines · Zhen Lei
Fix the incorrect return value check for
debugfs_create_file(), which returnsERR_PTR(-ERROR)instead of NULL when it fails.Based upon the commit text this change is incorrect.
* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway.
Quoted 5 lines
Quoted 3 lines
So ath11k should not be checking the return value at all, and definitely should not be returning
-EINVALsince the driver should still operate even if creating a debugfs file fails.OK, so that members such as
scan_ctlin structath11k_spectralcan be removed.
Sorry, the ath11k driver code is more complex than I think. I just went through the code, and those members still need to be kept.
Quoted 45 lines
I will update accordingly in v2.>
Quoted 43 lines
Quoted 31 lines
Fixes 9d11b7bff950 ("ath11k: add support for spectral scan")Signed-off-by Zhen Lei <[email protected]>--- drivers/net/wireless/ath/ath11k/spectral.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath11k/spectral.c +2
-2@@ -942,7 +942,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_ctl); -if (!ar->spectral.scan_ctl) { +if (IS_ERR (ar->spectral.scan_ctl)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;@@ -953,7 +953,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_count); -if (!ar->spectral.scan_count) { +if (IS_ERR (ar->spectral.scan_count)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;drivers/net/wireless/ath/ath11k/spectral.c static inline int ath11k_spectral_debug_register(struct ath11k *ar) · line 970
Quoted 8 lines
drivers/net/wireless/ath/ath11k/spectral.c +1
-1@@ -964,7 +964,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)0600 , ar->debug.debugfs_pdev, ar, &fops_scan_bins); -if (!ar->spectral.scan_bins) { +if (IS_ERR (ar->spectral.scan_bins)) {ath11k_warn (ar->ab,"failed to open debugfs in pdev %d\n" , ar->pdev_idx); ret = -EINVAL ;.
Signature · 2 lines
Regards, Zhen Lei