Skip to content

Commit d88c93f

Browse files
committed
debugfs: fix debugfs_rename parameter checking
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>
1 parent 3a34c98 commit d88c93f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/debugfs/inode.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,13 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
787787
struct dentry *dentry = NULL, *trap;
788788
struct name_snapshot old_name;
789789

790+
if (IS_ERR(old_dir))
791+
return old_dir;
792+
if (IS_ERR(new_dir))
793+
return new_dir;
794+
if (IS_ERR_OR_NULL(old_dentry))
795+
return old_dentry;
796+
790797
trap = lock_rename(new_dir, old_dir);
791798
/* Source or destination directories don't exist? */
792799
if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))

0 commit comments

Comments
 (0)