Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: mac80211: use IS_ERR to check return value
@ 2023-04-16  8:30 yingsha xu
  2023-04-18  8:36 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: yingsha xu @ 2023-04-16  8:30 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jiri Benc, John W. Linville
  Cc: hust-os-kernel-patches, yingsha xu, linux-wireless, netdev,
	linux-kernel

According to the annotation of function debugfs_create_fs, if
an error occurs, ERR_PTR(-ERROR) will be returned instead of
a null pointer or zero value.

Fix it by using IS_ERR().

Fixes: e9f207f0ff90 ("[MAC80211]: Add debugfs attributes.")
Signed-off-by: yingsha xu <ysxu@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
 net/mac80211/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index dfb9f55e2685..672bf969ad88 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -674,7 +674,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
 	statsd = debugfs_create_dir("statistics", phyd);
 
 	/* if the dir failed, don't put all the other things into the root! */
-	if (!statsd)
+	if (IS_ERR(statsd))
 		return;
 
 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mac80211: use IS_ERR to check return value
  2023-04-16  8:30 [PATCH] net: mac80211: use IS_ERR to check return value yingsha xu
@ 2023-04-18  8:36 ` Johannes Berg
  2023-04-19 11:23   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2023-04-18  8:36 UTC (permalink / raw)
  To: yingsha xu, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jiri Benc, John W. Linville
  Cc: hust-os-kernel-patches, linux-wireless, netdev, linux-kernel

On Sun, 2023-04-16 at 16:30 +0800, yingsha xu wrote:
> According to the annotation of function debugfs_create_fs, if
> an error occurs, ERR_PTR(-ERROR) will be returned instead of
> a null pointer or zero value.
> 
> Fix it by using IS_ERR().

I don't this this is right, or fixed anything ...

If debugfs indeed returned an ERR_PTR() value, then the later debugfs
adds will do nothing.

Since it doesn't look like debugfs_create_dir() can actually return NULL
these days (not sure it ever could), I guess we can even remove the
check.

But you could've just read the comment there too, to know what the NULL
check was about ...

johannes


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mac80211: use IS_ERR to check return value
  2023-04-18  8:36 ` Johannes Berg
@ 2023-04-19 11:23   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-04-19 11:23 UTC (permalink / raw)
  To: Johannes Berg
  Cc: yingsha xu, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jiri Benc, John W. Linville, hust-os-kernel-patches,
	linux-wireless, netdev, linux-kernel

On Tue, Apr 18, 2023 at 10:36:14AM +0200, Johannes Berg wrote:
> On Sun, 2023-04-16 at 16:30 +0800, yingsha xu wrote:
> > According to the annotation of function debugfs_create_fs, if
> > an error occurs, ERR_PTR(-ERROR) will be returned instead of
> > a null pointer or zero value.
> > 
> > Fix it by using IS_ERR().
> 
> I don't this this is right, or fixed anything ...
> 
> If debugfs indeed returned an ERR_PTR() value, then the later debugfs
> adds will do nothing.
> 
> Since it doesn't look like debugfs_create_dir() can actually return NULL
> these days (not sure it ever could), I guess we can even remove the
> check.
> 

Correct.  They have a patch ready which deletes the check and the
comment.  Someone should have replied to this thread to NAK their own
patch so that you didn't bother reviewing it.

> But you could've just read the comment there too, to know what the NULL
> check was about ...

The comment was always wrong.  Debugfs could return NULL but then
the other debugfs functions turned into no ops...

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-19 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16  8:30 [PATCH] net: mac80211: use IS_ERR to check return value yingsha xu
2023-04-18  8:36 ` Johannes Berg
2023-04-19 11:23   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox