eventfs: Fix failure path in eventfs_create_events_dir()

The failure path of allocating ei goes to a path that dereferences ei.
Add another label that skips over the ei dereferences to do the rest of
the clean up.

Link: https://lore.kernel.org/all/70e7bace-561c-95f-1117-706c2c220bc@inria.fr/
Link: https://lore.kernel.org/linux-trace-kernel/20231019204132.6662fef0@gandalf.local.home

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Fixes: 5790b1fb ("eventfs: Remove eventfs_file and just use eventfs_inode")
Reported-by: default avatarJulia Lawall <julia.lawall@inria.fr>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent b8a555dc
...@@ -735,7 +735,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry ...@@ -735,7 +735,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
ei = kzalloc(sizeof(*ei), GFP_KERNEL); ei = kzalloc(sizeof(*ei), GFP_KERNEL);
if (!ei) if (!ei)
goto fail; goto fail_ei;
inode = tracefs_get_inode(dentry->d_sb); inode = tracefs_get_inode(dentry->d_sb);
if (unlikely(!inode)) if (unlikely(!inode))
...@@ -781,6 +781,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry ...@@ -781,6 +781,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
fail: fail:
kfree(ei->d_children); kfree(ei->d_children);
kfree(ei); kfree(ei);
fail_ei:
tracefs_failed_creating(dentry); tracefs_failed_creating(dentry);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment