Skip to contentSkip to conversation

lib:Fix more error checking for debugfs_create_dir()

PATCH In review Wang Ming 2 participants 3 messages Jul 11, 2023 – Jul 12, 2023 1 message not in the archive Library code

lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH v2 1/1 lib:Fix more error checking for debugfs_create_dir()

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.

---
 lib/test_fpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_fpu.c +1 -1
index e82db19fed84..5d6aa4691b4a 100644
@@ -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,
Signature · 1 line
2.25.1
#1 lore raw

Hi--

Quoted 7 lines · Wang Ming

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.

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

Thanks.

Quoted 17 lines
---
 lib/test_fpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_fpu.c +1 -1
index e82db19fed84..5d6aa4691b4a 100644
@@ -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,
Signature · 1 line
~Randy

A message that is not in the archive (sent off-list or not yet received): SG2PR06MB3743963CD8DA3A48FC6C2122BD36A@SG2PR06MB3743.apcprd06.prod.outlook.com

#3 lore raw
Quoted 4 lines · 王明-软件底层技术部

Hi Randy.
The only maintainers I obtained using get_maintainer.pl were LKML, and there seems to be no other maintainers Do you have any good suggestions?: )

Use 'git log lib/test_fpu.c' to see who merges patches to it.

Quoted 44 lines

~Ming
-----邮件原件-----
发件人: Randy Dunlap <[email protected]>
发送时间: 2023年7月12日 3:33
收件人: 王明-软件底层技术部 <[email protected]>; [email protected] 抄送: opensource.kernel <[email protected]>
主题: Re: [PATCH v2] lib:Fix more error checking for debugfs_create_dir()

[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi--

Quoted 7 lines · Wang Ming

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.

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

Thanks.

Quoted 9 lines
---
 lib/test_fpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_fpu.c index renamed from lib/test_fpu.c +0 -0

e82db19fed84..5d6aa4691b4a 100644

lib/test_fpu.c static struct dentry *selftest_dir; static int · line 74

Quoted 7 lines
lib/test_fpu.c +1 -1
@@ -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

Signature · 1 line
~Randy