Thread (6 messages) 6 messages, 5 authors, 2023-08-31

Re: [PATCH] powerpc: fix debugfs_create_dir error checking

From: Immad Mir <hidden>
Date: 2023-06-03 22:35:27

Still I think this patch is an improvement so I'll plan to merge it.
Please let me know when you commit it.

Thanks
Immad.

On Tue, May 30, 2023 at 4:17 PM Michael Ellerman [off-list ref] wrote:
Greg KH [off-list ref] writes:
quoted
On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
quoted
From: Immad Mir <redacted>

The debugfs_create_dir returns ERR_PTR incase of an error and the
correct way of checking it by using the IS_ERR inline function, and
not the simple null comparision. This patch fixes this.

Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Immad Mir <redacted>
---
 arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c
b/arch/powerpc/platforms/powernv/opal-xscom.c
quoted
quoted
index 6b4eed2ef..262cd6fac 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root,
struct device_node *dn,
quoted
quoted
     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;
Why is this driver caring if debugfs is working or not at all?  It
should just ignore the error and keep moving forward.
It's creating directories and then creating files in those directories.
So I think it makes sense that it checks that the directory was created
successfully. It doesn't check whether the files were created.
quoted
And -1 is not a valid error number :(
It's EPERM :) - but yeah probably not really the right error in this
case.

Still I think this patch is an improvement so I'll plan to merge it.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help