lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
PATCH 1/1 lib:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in err_inject_init()
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.
--- lib/notifier-error-inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/notifier-error-inject.c +1 -1
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 16 lines · Wang Ming
The
debugfs_create_dir()function returns error pointers. It never returns NULL. Most incorrect error checks were fixed, but the one inerr_inject_init()was forgotten.Fix the remaining error check.
Signed-off-by Wang Ming <[email protected]>--- lib/notifier-error-inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/notifier-error-inject.c +0
-0
lib/notifier-error-inject.c static int __init err_inject_init(void) · line 87
Quoted 6 lines
lib/notifier-error-inject.c +1
-1@@ -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
A message that is not in the archive (sent off-list or not yet received): SG2PR06MB37435A03DEC11F265C849093BD37A@SG2PR06MB3743.apcprd06.prod.outlook.com
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
Quoted 5 lines · 王明-软件底层技术部
Hi greg k-h
I proposed this patch because I found thatdebugfs_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