eventfs: Remove extra dget() in eventfs_create_events_dir()
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 31 Oct 2023 16:42:29 +0000 (12:42 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 2 Nov 2023 03:45:05 +0000 (23:45 -0400)
The creation of the top events directory does a dget() at the end of the
creation in eventfs_create_events_dir() with a comment saying the final
dput() will happen when it is removed. The problem is that a dget() is
already done on the dentry when it was created with tracefs_start_creating()!
The dget() now just causes a memory leak of that dentry.

Remove the extra dget() as the final dput() in the deletion of the events
directory actually matches the one in tracefs_start_creating().

Link: https://lore.kernel.org/linux-trace-kernel/20231031124229.4f2e3fa1@gandalf.local.home
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Fixes: 5790b1fb3d672 ("eventfs: Remove eventfs_file and just use eventfs_inode")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
fs/tracefs/event_inode.c

index 4d2da7480e5f0f75cdca0cae1ed33372d1e5c7f1..5536860eb2ff7d27b6458357d12b9b8563c73ea9 100644 (file)
@@ -774,9 +774,6 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
        fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
        tracefs_end_creating(dentry);
 
-       /* Will call dput when the directory is removed */
-       dget(dentry);
-
        return ei;
 
  fail: