Skip to contentSkip to conversation

clk: clean up everything on debugfs error

PATCH RESEND New Alex Elder 2 participants 2 messages Nov 27, 2013 Common clk

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH RESEND 1/1 clk: clean up everything on debugfs error

[Maybe the third time will be the charm. -Alex]

If CONFIG_COMMON_CLK_DEBUG is defined, clk_debug_create_one() is called to populate a debugfs directory with a few entries that are common for all clock types.

If an error happens after creating the first one debugfs_remove() is called on the clock's directory. The problem with this is that no cleanup is done on the debugfs files already created in that
directory, so the directory never actually gets removed. This
problem is silently ignored.

Fix this by calling debugfs_remove_recursive() instead. Reset the clk->dentry field to null afterward, to ensure it can't be mistaken as a valid pointer.

---
 drivers/clk/clk.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/clk.c +0 -0
index 2cf2ea6..77fcd06 100644
@@ -272,7 +272,8 @@ static int clk_debug_create_one(struct clk *clk,

struct dentry *pdentry)
goto out;

err_out:
- debugfs_remove(clk->dentry);
+ debugfs_remove_recursive(clk->dentry);
+ clk->dentry = NULL;
out:
return ret;
}

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH RESEND 1/1 clk: clean up everything on debugfs error

Quoting Alex Elder (2013-11-27 07:39:49)

Quoted 12 lines

[Maybe the third time will be the charm. -Alex]

If CONFIG_COMMON_CLK_DEBUG is defined, clk_debug_create_one() is called to populate a debugfs directory with a few entries that are common for all clock types.

If an error happens after creating the first one debugfs_remove() is called on the clock's directory. The problem with this is that no cleanup is done on the debugfs files already created in that
directory, so the directory never actually gets removed. This
problem is silently ignored.

Quoted 5 lines

Fix this by calling debugfs_remove_recursive() instead. Reset the clk->dentry field to null afterward, to ensure it can't be mistaken as a valid pointer.

Thanks! Taken into clk-next.

Regards,
Mike

Quoted 21 lines
---
 drivers/clk/clk.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/clk.c +2 -1
index 2cf2ea6..77fcd06 100644
@@ -272,7 +272,8 @@ static int clk_debug_create_one(struct clk *clk,
 struct dentry *pdentry)
        goto out;
 
 err_out:
-       debugfs_remove(clk->dentry);
+       debugfs_remove_recursive(clk->dentry);
+       clk->dentry = NULL;
 out:
        return ret;

}

Signature · 1 line
1.7.9.5