[PATCH v2] lib:Fix more error checking for debugfs_create_dir()

Wang Ming posted 1 patch 2 years, 7 months ago
lib/test_fpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] lib:Fix more error checking for debugfs_create_dir()
Posted by Wang Ming 2 years, 7 months ago
In case of failure, debugfs_create_dir() does not return NULL,
but an error pointer.  Most incorrect error checks were fixed,
but the one in test_fpu_init() was forgotten.

Fix the remaining error check.

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

diff --git a/lib/test_fpu.c b/lib/test_fpu.c
index e82db19fed84..5d6aa4691b4a 100644
--- a/lib/test_fpu.c
+++ b/lib/test_fpu.c
@@ -69,7 +69,7 @@ static struct dentry *selftest_dir;
 static int __init test_fpu_init(void)
 {
 	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,
-- 
2.25.1
Re: [PATCH v2] lib:Fix more error checking for debugfs_create_dir()
Posted by Randy Dunlap 2 years, 7 months ago
Hi--

On 7/11/23 04:16, Wang Ming wrote:
> In case of failure, debugfs_create_dir() does not return NULL,
> but an error pointer.  Most incorrect error checks were fixed,
> but the one in test_fpu_init() was forgotten.
> 
> Fix the remaining error check.
> 
> Signed-off-by: Wang Ming <machel@vivo.com>

You need to send this to some maintainer who can merge it,
so please an appropriate maintainer to send it to.

Thanks.

> ---
>  lib/test_fpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_fpu.c b/lib/test_fpu.c
> index e82db19fed84..5d6aa4691b4a 100644
> --- a/lib/test_fpu.c
> +++ b/lib/test_fpu.c
> @@ -69,7 +69,7 @@ static struct dentry *selftest_dir;
>  static int __init test_fpu_init(void)
>  {
>  	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,

-- 
~Randy