debugfs: allow bad parent pointers to be passed in
authorGreg KH <gregkh@linuxfoundation.org>
Mon, 30 Mar 2015 12:59:15 +0000 (14:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 14:30:12 +0000 (16:30 +0200)
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.

Reported-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alex Elder <elder@linaro.org>
fs/debugfs/inode.c

index 96400ab42d135e7d572d29de9d4f3637fedd7817..61e72d44cf94142c1946f9dbc74904b8f31ec98e 100644 (file)
@@ -254,6 +254,9 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
 
        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)