summaryrefslogtreecommitdiffstats
path: root/fs/debugfs/inode.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-23 11:27:02 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-15 08:09:12 +0100
commitc87bdb9e8148c9955192d4ef4acdb889a557cd6d (patch)
tree0cfc30b2d5536df188561707653e10ad2af6c0ff /fs/debugfs/inode.c
parentaef80fd68017793d14fddc3b4ef8e1c050b44faf (diff)
downloadlinux-stable-c87bdb9e8148c9955192d4ef4acdb889a557cd6d.tar.gz
linux-stable-c87bdb9e8148c9955192d4ef4acdb889a557cd6d.tar.bz2
linux-stable-c87bdb9e8148c9955192d4ef4acdb889a557cd6d.zip
debugfs: fix debugfs_rename parameter checking
commit d88c93f090f708c18195553b352b9f205e65418f upstream. debugfs_rename() needs to check that the dentries passed into it really are valid, as sometimes they are not (i.e. if the return value of another debugfs call is passed into this one.) So fix this up by properly checking if the two parent directories are errors (they are allowed to be NULL), and if the dentry to rename is not NULL or an error. Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/debugfs/inode.c')
-rw-r--r--fs/debugfs/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index c59f015f386e..ccfe1e1cb6bc 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -766,6 +766,13 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
struct dentry *dentry = NULL, *trap;
struct name_snapshot old_name;
+ if (IS_ERR(old_dir))
+ return old_dir;
+ if (IS_ERR(new_dir))
+ return new_dir;
+ if (IS_ERR_OR_NULL(old_dentry))
+ return old_dentry;
+
trap = lock_rename(new_dir, old_dir);
/* Source or destination directories don't exist? */
if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))