Skip to contentSkip to conversation

powerpc:platforms:Fix an NULL vs IS_ERR() bug for debugfs_create_dir()

PATCH In review Wang Ming 1 participant 2 messages Jul 12, 2023 – Jul 26, 2023 PowerPC

lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH v2 1/1 powerpc:platforms:Fix an NULL vs IS_ERR() bug for debugfs_create_dir()

The debugfs_create_dir() function returns error pointers. It never returns NULL. Most incorrect error checks were fixed, but the one in scom_debug_init() was forgotten, the other one in scom_debug_init_one() was also forgotten.

Fix the remaining error check.

Fixes bfd2f0d49aef ("powerpc/powernv: Get rid of old scom_controller abstraction")
---
 arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/opal-xscom.c +2 -2
index 6b4eed2ef4fa..262cd6fac907 100644
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
 	ent->path.size = strlen((char *)ent->path.data);
 
 	dir = debugfs_create_dir(ent->name, root);
-	if (!dir) {
+	if (IS_ERR(dir)) {
 		kfree(ent->path.data);
 		kfree(ent);
 		return -1;
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
 		return 0;
 
 	root = debugfs_create_dir("scom", arch_debugfs_dir);
-	if (!root)
+	if (IS_ERR(root))
 		return -1;
 
 	rc = 0;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 28 lines · Wang Ming

The debugfs_create_dir() function returns error pointers. It never returns NULL. Most incorrect error checks were fixed, but the one in scom_debug_init() was forgotten, the other one in scom_debug_init_one() was also forgotten.

Fix the remaining error check.

Fixes bfd2f0d49aef ("powerpc/powernv: Get rid of old scom_controller abstraction")
---
  arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/opal-xscom.c +1 -1
index 6b4eed2ef4fa..262cd6fac907 100644
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
  	ent->path.size = strlen((char *)ent->path.data);
 
  	dir = debugfs_create_dir(ent->name, root);
-	if (!dir) {
+	if (IS_ERR(dir)) {
  		kfree(ent->path.data);
  		kfree(ent);
  		return -1;

arch/powerpc/platforms/powernv/opal-xscom.c static int scom_debug_init(void) · line 196

Quoted 8 lines
arch/powerpc/platforms/powernv/opal-xscom.c +1 -1
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
  		return 0;
 
  	root = debugfs_create_dir("scom", arch_debugfs_dir);
-	if (!root)
+	if (IS_ERR(root))
  		return -1;
 
  	rc = 0;

hi

This patch has not received any reply so far, please check it

ping: https://lore.kernel.org/all/[email protected]/