2023-09-14 03:34:25

by Jinjie Ruan

[permalink] [raw]
Subject: [PATCH] rtw88: debug: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file()

Since debugfs_create_file() return ERR_PTR and never return NULL, so use
IS_ERR() to check it instead of checking NULL.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Signed-off-by: Jinjie Ruan <[email protected]>
---
drivers/net/wireless/realtek/rtw88/debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
index f8ba133baff0..35bc37a3c469 100644
--- a/drivers/net/wireless/realtek/rtw88/debug.c
+++ b/drivers/net/wireless/realtek/rtw88/debug.c
@@ -1233,9 +1233,9 @@ static struct rtw_debugfs_priv rtw_debug_priv_dm_cap = {
#define rtw_debugfs_add_core(name, mode, fopname, parent) \
do { \
rtw_debug_priv_ ##name.rtwdev = rtwdev; \
- if (!debugfs_create_file(#name, mode, \
+ if (IS_ERR(debugfs_create_file(#name, mode, \
parent, &rtw_debug_priv_ ##name,\
- &file_ops_ ##fopname)) \
+ &file_ops_ ##fopname))) \
pr_debug("Unable to initialize debugfs:%s\n", \
#name); \
} while (0)
--
2.34.1


2023-09-15 06:22:00

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH] rtw88: debug: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file()



> -----Original Message-----
> From: Jinjie Ruan <[email protected]>
> Sent: Thursday, September 14, 2023 11:29 AM
> To: [email protected]; Ping-Ke Shih <[email protected]>; Kalle Valo <[email protected]>;
> Stanislaw Gruszka <[email protected]>; Brian Norris <[email protected]>; Yan-Hsuan Chuang
> <[email protected]>
> Cc: [email protected]
> Subject: [PATCH] rtw88: debug: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file()

Excepting to typo "Fix Fix" in subject, patch looks fine to me.

>
>
> Since debugfs_create_file() return ERR_PTR and never return NULL, so use
> IS_ERR() to check it instead of checking NULL.
>
> Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
> Signed-off-by: Jinjie Ruan <[email protected]>

Acked-by: Ping-Ke Shih <[email protected]>

> ---
> drivers/net/wireless/realtek/rtw88/debug.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
> index f8ba133baff0..35bc37a3c469 100644
> --- a/drivers/net/wireless/realtek/rtw88/debug.c
> +++ b/drivers/net/wireless/realtek/rtw88/debug.c
> @@ -1233,9 +1233,9 @@ static struct rtw_debugfs_priv rtw_debug_priv_dm_cap = {
> #define rtw_debugfs_add_core(name, mode, fopname, parent) \
> do { \
> rtw_debug_priv_ ##name.rtwdev = rtwdev; \
> - if (!debugfs_create_file(#name, mode, \
> + if (IS_ERR(debugfs_create_file(#name, mode, \
> parent, &rtw_debug_priv_ ##name,\
> - &file_ops_ ##fopname)) \
> + &file_ops_ ##fopname))) \
> pr_debug("Unable to initialize debugfs:%s\n", \
> #name); \
> } while (0)
> --
> 2.34.1