Skip to contentSkip to conversation

debugfs: change parameter check in debugfs_remove() functions

PATCH In review Arend van Spriel 2 participants 2 messages May 23, 2012 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 debugfs: change parameter check in debugfs_remove() functions

The dentry parameter in debugfs_remove() and debugfs_remove_recursive() is checked being a NULL pointer. To make cleanup by callers easier this check is extended using the IS_ERR_OR_NULL macro instead because the debugfs_create_... functions can return a ERR_PTR() value.

---
I was adding the check in driver code before calling the recursive remove, but considered it might be a better idea to do it in debugfs itself.

No rush so I target to include it in v3.6. The patch is based on v3.4 tag.

Gr. AvS

---
 fs/debugfs/inode.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/debugfs/inode.c +2 -2
index b80bc84..0de5e26 100644
@@ -498,7 +498,7 @@ void debugfs_remove(struct dentry *dentry)
 	struct dentry *parent;
 	int ret;
 
-	if (!dentry)
+	if (IS_ERR_OR_NULL(dentry))
 		return;
 
 	parent = dentry->d_parent;
@@ -530,7 +530,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
 	struct dentry *child;
 	struct dentry *parent;
 
-	if (!dentry)
+	if (IS_ERR_OR_NULL(dentry))
 		return;
 
 	parent = dentry->d_parent;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 9 lines · Arend van Spriel

The dentry parameter in debugfs_remove() and debugfs_remove_recursive() is checked being a NULL pointer. To make cleanup by callers easier this check is extended using the IS_ERR_OR_NULL macro instead because the debugfs_create_... functions can return a ERR_PTR() value.

---
I was adding the check in driver code before calling the recursive remove, but considered it might be a better idea to do it in debugfs itself.

Yes, nice change, thanks.

I'll queue it up after 3.5-rc1 is out.

thanks,

greg k-h