Skip to content

Commit db3a397

Browse files
committed
eventfs: Have a free_ei() that just frees the eventfs_inode
As the eventfs_inode is freed in two different locations, make a helper function free_ei() to make sure all the allocated fields of the eventfs_inode is freed. This requires renaming the existing free_ei() which is called by the srcu handler to free_rcu_ei() and have free_ei() just do the freeing, where free_rcu_ei() will call it. Link: https://lkml.kernel.org/r/20231101172649.265214087@goodmis.org Cc: Ajay Kaher <akaher@vmware.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent f2f4963 commit db3a397

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fs/tracefs/event_inode.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ static struct dentry *create_dir(const char *name, struct dentry *parent)
129129
return eventfs_end_creating(dentry);
130130
}
131131

132+
static void free_ei(struct eventfs_inode *ei)
133+
{
134+
kfree_const(ei->name);
135+
kfree(ei->d_children);
136+
kfree(ei);
137+
}
138+
132139
/**
133140
* eventfs_set_ei_status_free - remove the dentry reference from an eventfs_inode
134141
* @ti: the tracefs_inode of the dentry
@@ -168,9 +175,7 @@ void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry)
168175
eventfs_remove_dir(ei_child);
169176
}
170177

171-
kfree_const(ei->name);
172-
kfree(ei->d_children);
173-
kfree(ei);
178+
free_ei(ei);
174179
return;
175180
}
176181

@@ -784,13 +789,11 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
784789
return ERR_PTR(-ENOMEM);
785790
}
786791

787-
static void free_ei(struct rcu_head *head)
792+
static void free_rcu_ei(struct rcu_head *head)
788793
{
789794
struct eventfs_inode *ei = container_of(head, struct eventfs_inode, rcu);
790795

791-
kfree_const(ei->name);
792-
kfree(ei->d_children);
793-
kfree(ei);
796+
free_ei(ei);
794797
}
795798

796799
/**
@@ -881,7 +884,7 @@ void eventfs_remove_dir(struct eventfs_inode *ei)
881884
for (i = 0; i < ei->nr_entries; i++)
882885
unhook_dentry(&ei->d_children[i], &dentry_list);
883886
unhook_dentry(&ei->dentry, &dentry_list);
884-
call_srcu(&eventfs_srcu, &ei->rcu, free_ei);
887+
call_srcu(&eventfs_srcu, &ei->rcu, free_rcu_ei);
885888
}
886889
mutex_unlock(&eventfs_mutex);
887890

0 commit comments

Comments
 (0)