Skip to contentSkip to conversation

staging: kernel.h: Prevent macro expantion bug in container_of_safe()

PATCH New Dan Carpenter 2 participants 2 messages Apr 26, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: kernel.h: Prevent macro expantion bug in container_of_safe()

There aren't many users of this so it doesn't cause a problem, but we obviously want to use "__mptr" here instead of "ptr" to prevent the parameter from being executed twice.

include/linux/kernel.h +1 -1
index b5a8e78c6c75..593fb8d250a2 100644
@@ -978,7 +978,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
 			 !__same_type(*(ptr), void),			\
 			 "pointer type mismatch in container_of()");	\
-	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
+	IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) :			\
 		((type *)(__mptr - offsetof(type, member))); })
 
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
#1 lore raw

PATCH 1/1 staging: kernel.h: Prevent macro expantion bug in container_of_safe()

Quoted 11 lines · Dan Carpenter

There aren't many users of this so it doesn't cause a problem, but we obviously want to use "__mptr" here instead of "ptr" to prevent the parameter from being executed twice.

include/linux/kernel.h +0 -0
index b5a8e78c6c75..593fb8d250a2 100644

include/linux/kernel.h static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } · line 984

Quoted 8 lines
include/linux/kernel.h +1 -1
@@ -978,7 +978,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
 			 !__same_type(*(ptr), void),			\
 			 "pointer type mismatch in container_of()");	\
-	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
+	IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) :			\
 		((type *)(__mptr - offsetof(type, member))); })
 
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */

Arg, of course. Thanks.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180426/374eb610/attachment.sig>