public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
@ 2023-07-12 13:52 Wang Ming
  2023-07-12 16:34 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Ming @ 2023-07-12 13:52 UTC (permalink / raw)
  To: David Hildenbrand, Greg Kroah-Hartman, Akinobu Mita, Wang Ming,
	Andrew Morton, linux-kernel
  Cc: opensource.kernel

The debugfs_create_dir() function returns error pointers.
It never returns NULL. Most incorrect error checks were fixed,
but the one in err_inject_init() was forgotten.

Fix the remaining error check.

Signed-off-by: Wang Ming <machel@vivo.com>
---
 lib/notifier-error-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c
index 2b24ea6c9497..c49354c23802 100644
--- a/lib/notifier-error-inject.c
+++ b/lib/notifier-error-inject.c
@@ -83,7 +83,7 @@ static int __init err_inject_init(void)
 	notifier_err_inject_dir =
 		debugfs_create_dir("notifier-error-inject", NULL);
 
-	if (!notifier_err_inject_dir)
+	if (IS_ERR(notifier_err_inject_dir))
 		return -ENOMEM;
 
 	return 0;
-- 
2.25.1


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

* Re: [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
  2023-07-12 13:52 [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init() Wang Ming
@ 2023-07-12 16:34 ` Greg Kroah-Hartman
       [not found]   ` <SG2PR06MB37435A03DEC11F265C849093BD37A@SG2PR06MB3743.apcprd06.prod.outlook.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-12 16:34 UTC (permalink / raw)
  To: Wang Ming
  Cc: David Hildenbrand, Akinobu Mita, Andrew Morton, linux-kernel,
	opensource.kernel

On Wed, Jul 12, 2023 at 09:52:11PM +0800, Wang Ming wrote:
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL. Most incorrect error checks were fixed,
> but the one in err_inject_init() was forgotten.
> 
> Fix the remaining error check.
> 
> Signed-off-by: Wang Ming <machel@vivo.com>
> ---
>  lib/notifier-error-inject.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c
> index 2b24ea6c9497..c49354c23802 100644
> --- a/lib/notifier-error-inject.c
> +++ b/lib/notifier-error-inject.c
> @@ -83,7 +83,7 @@ static int __init err_inject_init(void)
>  	notifier_err_inject_dir =
>  		debugfs_create_dir("notifier-error-inject", NULL);
>  
> -	if (!notifier_err_inject_dir)
> +	if (IS_ERR(notifier_err_inject_dir))
>  		return -ENOMEM;

Please do not do any different codepath if a debugfs_*() call fails or
succeeds.

Why do you need to check this at all?

And why are you creating this directory at the root of debugfs?

thanks,

greg k-h

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

* Re: 回复: [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
       [not found]   ` <SG2PR06MB37435A03DEC11F265C849093BD37A@SG2PR06MB3743.apcprd06.prod.outlook.com>
@ 2023-07-13  6:01     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-13  6:01 UTC (permalink / raw)
  To: 王明-软件底层技术部
  Cc: David Hildenbrand, Akinobu Mita, Andrew Morton, LKML,
	opensource.kernel


A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Thu, Jul 13, 2023 at 02:09:03AM +0000, 王明-软件底层技术部 wrote:
> Hi greg k-h
> I proposed this patch because I found that debugfs_create_dir() does
> not return NULL, but returns an error pointer, executing if statements
> according to the original code meaning no error, so I made this change
> : )

That's fine, but you should fix this up to use the api properly if you
are making these types of changes, otherwise we just have to do it again
in the future.

thanks,

greg k-h

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

end of thread, other threads:[~2023-07-13  6:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-12 13:52 [PATCH v1] lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init() Wang Ming
2023-07-12 16:34 ` Greg Kroah-Hartman
     [not found]   ` <SG2PR06MB37435A03DEC11F265C849093BD37A@SG2PR06MB3743.apcprd06.prod.outlook.com>
2023-07-13  6:01     ` 回复: " Greg Kroah-Hartman

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