path: root/fs/tracefs/inode.c
diff options
authorDaniel Borkmann <>2015-11-04 23:33:17 +0100
committerSteven Rostedt <>2015-11-04 22:13:45 -0500
commitd227c3ae4e94e5eb11dd780a811f59e1a7b74ccd (patch)
tree1335f64815650b7f1cf7ec457e3453a78bc88a77 /fs/tracefs/inode.c
parent43ed384339ae67a74a8ba4851268b23216ef7a44 (diff)
tracefs: Fix refcount imbalance in start_creating()
In tracefs' 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 singleton 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. F.e., in securityfs_create_file(), after doing simple_pin_fs() when lookup_one_len() fails there, we infact do simple_release_fs(). This seems necessary here as well. Same issue seen in debugfs due to 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off"), which seemed to got carried over into tracefs, too. Noticed during code review. Link: Fixes: 4282d60689d4 ("tracefs: Add new tracefs file system") Cc: # 4.1+ Signed-off-by: Daniel Borkmann <> Signed-off-by: Steven Rostedt <>
Diffstat (limited to 'fs/tracefs/inode.c')
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index cbc8d5d2755a..c66f2423e1f5 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -340,8 +340,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
dentry = ERR_PTR(-EEXIST);
- if (IS_ERR(dentry))
+ if (IS_ERR(dentry)) {
+ simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ }
return dentry;