Skip to content

Commit

Permalink
eventfs: Make sure that parent->d_inode is locked in creating files/dirs
Browse files Browse the repository at this point in the history
Since the locking of the parent->d_inode has been moved outside the
creation of the files and directories (as it use to be locked via a
conditional), add a WARN_ON_ONCE() to the case that it's not locked.

Link: https://lkml.kernel.org/r/[email protected]

Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Andrew Morton <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
rostedt committed Nov 22, 2023
1 parent fc45612 commit f49f950
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/tracefs/event_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
struct dentry **e_dentry = &ei->d_children[idx];
struct dentry *dentry;

WARN_ON_ONCE(!inode_is_locked(parent->d_inode));

mutex_lock(&eventfs_mutex);
if (ei->is_freed) {
mutex_unlock(&eventfs_mutex);
Expand Down Expand Up @@ -430,6 +432,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
{
struct dentry *dentry = NULL;

WARN_ON_ONCE(!inode_is_locked(parent->d_inode));

mutex_lock(&eventfs_mutex);
if (pei->is_freed || ei->is_freed) {
mutex_unlock(&eventfs_mutex);
Expand Down

0 comments on commit f49f950

Please sign in to comment.