Skip to content

Commit b8a555d

Browse files
nathanchancerostedt
authored andcommitted
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: ClangBuiltLinux#1947 Fixes: 5790b1f ("eventfs: Remove eventfs_file and just use eventfs_inode") Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 5ddd8ba commit b8a555d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/tracefs/event_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
731731
return NULL;
732732

733733
if (IS_ERR(dentry))
734-
return (struct eventfs_inode *)dentry;
734+
return ERR_CAST(dentry);
735735

736736
ei = kzalloc(sizeof(*ei), GFP_KERNEL);
737737
if (!ei)

0 commit comments

Comments
 (0)