Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6de51b2 authored by Rusty Russell's avatar Rusty Russell
Browse files

param: don't deref arg in __same_type() checks



gcc allows this when arg is a function, but sparse complains:

drivers/char/ipmi/ipmi_watchdog.c:303:1: error: cannot dereference this type
drivers/char/ipmi/ipmi_watchdog.c:307:1: error: cannot dereference this type
drivers/char/ipmi/ipmi_watchdog.c:311:1: error: cannot dereference this type

Reported-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Tested-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 4ef2db01
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -125,7 +125,7 @@ struct kparam_array
 */
 */
#define module_param_cb(name, ops, arg, perm)				      \
#define module_param_cb(name, ops, arg, perm)				      \
	__module_param_call(MODULE_PARAM_PREFIX,			      \
	__module_param_call(MODULE_PARAM_PREFIX,			      \
			    name, ops, arg, __same_type(*(arg), bool), perm)
			    name, ops, arg, __same_type((arg), bool *), perm)


/* On alpha, ia64 and ppc64 relocations to global data cannot go into
/* On alpha, ia64 and ppc64 relocations to global data cannot go into
   read-only sections (which is part of respective UNIX ABI on these
   read-only sections (which is part of respective UNIX ABI on these
@@ -157,7 +157,7 @@ struct kparam_array
		 { (void *)set, (void *)get };				\
		 { (void *)set, (void *)get };				\
	__module_param_call(MODULE_PARAM_PREFIX,			\
	__module_param_call(MODULE_PARAM_PREFIX,			\
			    name, &__param_ops_##name, arg,		\
			    name, &__param_ops_##name, arg,		\
			    __same_type(*(arg), bool),			\
			    __same_type(arg, bool *),			\
			    (perm) + sizeof(__check_old_set_param(set))*0)
			    (perm) + sizeof(__check_old_set_param(set))*0)


/* We don't get oldget: it's often a new-style param_get_uint, etc. */
/* We don't get oldget: it's often a new-style param_get_uint, etc. */
@@ -330,9 +330,9 @@ extern int param_get_bool(char *buffer, const struct kernel_param *kp);
#define param_check_bool(name, p)					\
#define param_check_bool(name, p)					\
	static inline void __check_##name(void)				\
	static inline void __check_##name(void)				\
	{								\
	{								\
		BUILD_BUG_ON(!__same_type(*(p), bool) &&		\
		BUILD_BUG_ON(!__same_type((p), bool *) &&		\
			     !__same_type(*(p), unsigned int) &&	\
			     !__same_type((p), unsigned int *) &&	\
			     !__same_type(*(p), int));			\
			     !__same_type((p), int *));			\
	}
	}


extern struct kernel_param_ops param_ops_invbool;
extern struct kernel_param_ops param_ops_invbool;