* [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
@ 2023-07-12 12:42 Minjie Du
2023-07-12 18:27 ` Luis Chamberlain
2023-07-13 16:00 ` [PATCH v1] " Jeff Johnson
0 siblings, 2 replies; 5+ messages in thread
From: Minjie Du @ 2023-07-12 12:42 UTC (permalink / raw)
To: Jiri Slaby, Nick Kossifidis, Luis Chamberlain, Kalle Valo,
open list:ATHEROS ATH5K WIRELESS DRIVER, open list
Cc: opensource.kernel, Minjie Du
Make IS_ERR() judge the debugfs_create_dir() function return
in ath5k_debug_init_device().
Signed-off-by: Minjie Du <duminjie@vivo.com>
---
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..08058b3f7 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(phydir))
return;
debugfs_create_file("debug", 0600, phydir, ah, &fops_debug);
--
2.39.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
2023-07-12 12:42 [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device Minjie Du
@ 2023-07-12 18:27 ` Luis Chamberlain
[not found] ` <3e831a9c-b469-f1d3-1eaf-c9e275a74da5@web.de>
2023-07-13 16:00 ` [PATCH v1] " Jeff Johnson
1 sibling, 1 reply; 5+ messages in thread
From: Luis Chamberlain @ 2023-07-12 18:27 UTC (permalink / raw)
To: Minjie Du
Cc: Jiri Slaby, Nick Kossifidis, Kalle Valo,
open list:ATHEROS ATH5K WIRELESS DRIVER, open list,
opensource.kernel
On Wed, Jul 12, 2023 at 08:42:59PM +0800, Minjie Du wrote:
> Make IS_ERR() judge the debugfs_create_dir() function return
> in ath5k_debug_init_device().
>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
> 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..08058b3f7 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(phydir))
Please use IS_ERR_OR_NULL() instead.
With that change added:
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
[not found] ` <3e831a9c-b469-f1d3-1eaf-c9e275a74da5@web.de>
@ 2023-07-13 5:47 ` Jiri Slaby
2023-07-24 8:01 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Jiri Slaby @ 2023-07-13 5:47 UTC (permalink / raw)
To: Markus Elfring, Luis Chamberlain, Minjie Du, linux-wireless,
kernel-janitors
Cc: opensource.kernel, LKML, Kalle Valo, Nick Kossifidis
On 12. 07. 23, 21:07, Markus Elfring wrote:
>>> +++ 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(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.
> 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,
--
js
suse labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
2023-07-12 12:42 [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device Minjie Du
2023-07-12 18:27 ` Luis Chamberlain
@ 2023-07-13 16:00 ` Jeff Johnson
1 sibling, 0 replies; 5+ messages in thread
From: Jeff Johnson @ 2023-07-13 16:00 UTC (permalink / raw)
To: Minjie Du, Jiri Slaby, Nick Kossifidis, Luis Chamberlain,
Kalle Valo, open list:ATHEROS ATH5K WIRELESS DRIVER, open list
Cc: opensource.kernel
subject prefix should be "wifi: ath5k: "
On 7/12/2023 5:42 AM, Minjie Du wrote:
> Make IS_ERR() judge the debugfs_create_dir() function return
> in ath5k_debug_init_device().
>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
> 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..08058b3f7 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(phydir))
> return;
>
> debugfs_create_file("debug", 0600, phydir, ah, &fops_debug);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device
2023-07-13 5:47 ` [PATCH] " Jiri Slaby
@ 2023-07-24 8:01 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2023-07-24 8:01 UTC (permalink / raw)
To: Jiri Slaby
Cc: Markus Elfring, Luis Chamberlain, Minjie Du, linux-wireless,
kernel-janitors, opensource.kernel, LKML, Kalle Valo,
Nick Kossifidis
On Thu, Jul 13, 2023 at 07:47:53AM +0200, Jiri Slaby wrote:
> On 12. 07. 23, 21:07, Markus Elfring wrote:
> > > > +++ 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(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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-24 8:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 12:42 [PATCH v1] drivers: wireless: ath5k: fix parameter check in ath5k_debug_init_device Minjie Du
2023-07-12 18:27 ` Luis Chamberlain
[not found] ` <3e831a9c-b469-f1d3-1eaf-c9e275a74da5@web.de>
2023-07-13 5:47 ` [PATCH] " Jiri Slaby
2023-07-24 8:01 ` Dan Carpenter
2023-07-13 16:00 ` [PATCH v1] " Jeff Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®