Skip to content

Commit

Permalink
debugfs: fix refcount imbalance in start_creating
Browse files Browse the repository at this point in the history
commit 0ee9608 upstream.

In debugfs' start_creating(), we pin the file system to safely access
its root. When we failed to create a file, we unpin the file system via
failed_creating() to release the mount count and eventually the reference
of the vfsmount.

However, when we run into an error during lookup_one_len() when still
in start_creating(), we only release the parent's mutex but not so the
reference on the mount. Looks like it was done in the past, but after
splitting portions of __create_file() into start_creating() and
end_creating() via 190afd8 ("debugfs: split the beginning and the
end of __create_file() off"), this seemed missed. Noticed during code
review.

Fixes: 190afd8 ("debugfs: split the beginning and the end of __create_file() off")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Daniel Borkmann authored and Greg Kroah-Hartman committed Dec 15, 2015
1 parent 3c10560 commit 03ecdde
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
dput(dentry);
dentry = ERR_PTR(-EEXIST);
}
if (IS_ERR(dentry))

if (IS_ERR(dentry)) {
mutex_unlock(&d_inode(parent)->i_mutex);
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
}

return dentry;
}

Expand Down

0 comments on commit 03ecdde

Please sign in to comment.