]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracefs: fix a leak in eventfs_create_events_dir()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 Oct 2025 22:13:48 +0000 (18:13 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 16 Nov 2025 06:35:01 +0000 (01:35 -0500)
If we have LOCKDOWN_TRACEFS, the function bails out - *after*
having locked the parent directory and without bothering to
undo that.  Just check it before tracefs_start_creating()...

Fixes: e24709454c45 "tracefs/eventfs: Add missing lockdown checks"
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/tracefs/event_inode.c

index 8705c77a9e75a1de02078fe674d689e2db124cbe..93c231601c8e23cb891e6b039d3d5b13013b3951 100644 (file)
@@ -757,7 +757,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
                                                const struct eventfs_entry *entries,
                                                int size, void *data)
 {
-       struct dentry *dentry = tracefs_start_creating(name, parent);
+       struct dentry *dentry;
        struct eventfs_root_inode *rei;
        struct eventfs_inode *ei;
        struct tracefs_inode *ti;
@@ -768,6 +768,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
        if (security_locked_down(LOCKDOWN_TRACEFS))
                return NULL;
 
+       dentry = tracefs_start_creating(name, parent);
        if (IS_ERR(dentry))
                return ERR_CAST(dentry);