Skip to content

Commit fc45612

Browse files
committed
eventfs: Do not allow NULL parent to eventfs_start_creating()
The eventfs directory is dynamically created via the meta data supplied by the existing trace events. All files and directories in eventfs has a parent. Do not allow NULL to be passed into eventfs_start_creating() as the parent because that should never happen. Warn if it does. 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]>
1 parent bcae32c commit fc45612

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/tracefs/inode.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *name, struct dentry *parent)
509509
struct dentry *dentry;
510510
int error;
511511

512+
/* Must always have a parent. */
513+
if (WARN_ON_ONCE(!parent))
514+
return ERR_PTR(-EINVAL);
515+
512516
error = simple_pin_fs(&trace_fs_type, &tracefs_mount,
513517
&tracefs_mount_count);
514518
if (error)
515519
return ERR_PTR(error);
516520

517-
/*
518-
* If the parent is not specified, we create it in the root.
519-
* We need the root dentry to do this, which is in the super
520-
* block. A pointer to that is in the struct vfsmount that we
521-
* have around.
522-
*/
523-
if (!parent)
524-
parent = tracefs_mount->mnt_root;
525-
526521
if (unlikely(IS_DEADDIR(parent->d_inode)))
527522
dentry = ERR_PTR(-ENOENT);
528523
else

0 commit comments

Comments
 (0)