2023-07-13 03:53:30

by Minjie Du

[permalink] [raw]
Subject: [PATCH v2] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device()

Make IS_ERR_OR_NULL() judge the debugfs_create_dir() function return
in ath5k_debug_init_device().

Signed-off-by: Minjie Du <[email protected]>
Acked-by: Luis Chamberlain <[email protected]>
---
v1-v2:
use IS_ERR_OR_NULL() instead of IS_ERR()
---
drivers/net/wireless/ath/ath5k/debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 4b41160e5..7c8823759 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -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_OR_NULL(phydir))
return;

debugfs_create_file("debug", 0600, phydir, ah, &fops_debug);
--
2.39.0



2023-07-13 05:23:04

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH v2] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device()

On 13. 07. 23, 5:36, Minjie Du wrote:
> Make IS_ERR_OR_NULL() judge the debugfs_create_dir() function return
> in ath5k_debug_init_device().
>
> Signed-off-by: Minjie Du <[email protected]>
> Acked-by: Luis Chamberlain <[email protected]>
> ---
> v1-v2:
> use IS_ERR_OR_NULL() instead of IS_ERR()
> ---
> drivers/net/wireless/ath/ath5k/debug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
> index 4b41160e5..7c8823759 100644
> --- a/drivers/net/wireless/ath/ath5k/debug.c
> +++ b/drivers/net/wireless/ath/ath5k/debug.c
> @@ -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_OR_NULL(phydir))

When can debugfs_create_dir() return NULL?

> return;
>
> debugfs_create_file("debug", 0600, phydir, ah, &fops_debug);

--
js
suse labs


2023-07-13 06:05:02

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH v2] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device()

On 13. 07. 23, 5:36, Minjie Du wrote:
> Make IS_ERR_OR_NULL() judge the debugfs_create_dir() function return
> in ath5k_debug_init_device().
>
> Signed-off-by: Minjie Du <[email protected]>
> Acked-by: Luis Chamberlain <[email protected]>
> ---
> v1-v2:
> use IS_ERR_OR_NULL() instead of IS_ERR()
> ---
> drivers/net/wireless/ath/ath5k/debug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
> index 4b41160e5..7c8823759 100644
> --- a/drivers/net/wireless/ath/ath5k/debug.c
> +++ b/drivers/net/wireless/ath/ath5k/debug.c
> @@ -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_OR_NULL(phydir))
> return;

And actually, in this case, remove the check completely (as per docs).

thanks,
--
js
suse labs