Commit b8a555dc authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Steven Rostedt (Google)

eventfs: Use ERR_CAST() in eventfs_create_events_dir()

When building with clang and CONFIG_RANDSTRUCT_FULL=y, there is an error
due to a cast in eventfs_create_events_dir():

  fs/tracefs/event_inode.c:734:10: error: casting from randomized structure pointer type 'struct dentry *' to 'struct eventfs_inode *'
    734 |                 return (struct eventfs_inode *)dentry;
        |                        ^
  1 error generated.

Use the ERR_CAST() function to resolve the error, as it was designed for
this exact situation (casting an error pointer to another type).

Link: https://lore.kernel.org/linux-trace-kernel/20231018-ftrace-fix-clang-randstruct-v1-1-338cb214abfb@kernel.org

Closes: https://github.com/ClangBuiltLinux/linux/issues/1947
Fixes: 5790b1fb ("eventfs: Remove eventfs_file and just use eventfs_inode")
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 5ddd8baa
...@@ -731,7 +731,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry ...@@ -731,7 +731,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
return NULL; return NULL;
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return (struct eventfs_inode *)dentry; return ERR_CAST(dentry);
ei = kzalloc(sizeof(*ei), GFP_KERNEL); ei = kzalloc(sizeof(*ei), GFP_KERNEL);
if (!ei) if (!ei)
......
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