Skip to contentSkip to conversation

debugfs: allow bad parent pointers to be passed in

PATCH In review Greg KH 3 participants 3 messages Mar 30, 2015 Driver core

lore
Share & tools
lore

Greg KH

author maintainer
#0 lore raw

PATCH 1/1 debugfs: allow bad parent pointers to be passed in

If something went wrong with creating a debugfs file/symlink/directory, that value could be passed down into debugfs again as a parent dentry. To make caller code simpler, just error out if this happens, and don't crash the kernel.

---
 fs/debugfs/inode.c |    3 +++
 1 file changed, 3 insertions(+)
fs/debugfs/inode.c +3 -0
@@ -254,6 +254,9 @@ static struct dentry *start_creating(con
 
 	pr_debug("debugfs: creating file '%s'\n",name);
 
+	if (IS_ERR(parent))
+		return parent;
+
 	error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
 			      &debugfs_mount_count);
 	if (error)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Greg KH

If something went wrong with creating a debugfs file/symlink/directory, that value could be passed down into debugfs again as a parent dentry. To make caller code simpler, just error out if this happens, and don't crash the kernel.

---
 fs/debugfs/inode.c |    3 +++
 1 file changed, 3 insertions(+)

fs/debugfs/inode.c static struct dentry *start_creating(con · line 262

Quoted 9 lines
fs/debugfs/inode.c +3 -0
@@ -254,6 +254,9 @@ static struct dentry *start_creating(con
 
        pr_debug("debugfs: creating file '%s'\n",name);
 
+       if (IS_ERR(parent))
+               return parent;
+
        error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
                              &debugfs_mount_count);
        if (error)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Greg KH
Quoted 8 lines · Greg KH

If something went wrong with creating a debugfs file/symlink/directory, that value could be passed down into debugfs again as a parent dentry. To make caller code simpler, just error out if this happens, and don't crash the kernel.

Looks good.

Quoted 18 lines
---
 fs/debugfs/inode.c |    3 +++
 1 file changed, 3 insertions(+)
fs/debugfs/inode.c +3 -0
@@ -254,6 +254,9 @@ static struct dentry *start_creating(con
 
 	pr_debug("debugfs: creating file '%s'\n",name);
 
+	if (IS_ERR(parent))
+		return parent;
+
 	error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
 			      &debugfs_mount_count);
 	if (error)