lib:Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
PATCH 1/1 lib:Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
The debugfs_create_dir() function returns error pointers. It never returns NULL. So use IS_ERR() to check it.
Signed-off-by Yang Ruibin <[email protected]>
--- lib/test_fpu_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_fpu_glue.c +1 -1
@@ -42,7 +42,7 @@ static int __init test_fpu_init(void)return -EINVAL ; selftest_dir =debugfs_create_dir ("selftest_helpers" ,NULL ); -if (!selftest_dir) +if (IS_ERR (selftest_dir))return -ENOMEM ; debugfs_create_file_unsafe("test_fpu", 0444, selftest_dir, NULL,
Signature · 1 line
2.34.1
Wed, Aug 21, 2024 at 03:34:40AM -0400, Yang Ruibin kirjoitti:
lib/test_fpu_glue.c static int __init test_fpu_init(void) · line 46
Quoted 7 lines
The
debugfs_create_dir()function returns error pointers. It never returns NULL. So useIS_ERR()to check it.lib/test_fpu_glue.c +1
-1selftest_dir =debugfs_create_dir ("selftest_helpers" ,NULL ); -if (!selftest_dir) +if (IS_ERR (selftest_dir))return -ENOMEM ;
With this you most likely want to propagate error code to the caller
return PTR_ERR(selftest_dir);
BUT, we usually don't check debugfs error codes as the program should work anyway. Does this test case actually _rely_ on debugfs to be functional?
Signature · 2 lines
With Best Regards, Andy Shevchenko