* [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
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