Commit bafeafeab94b8d3019aac15c2df2ce47b08a6363

Authored by Rusty Russell
1 parent e49ce14150

module_param: check type correctness for module_param_array

module_param_array(), unlike its non-array cousins, didn't check the type
of the variable.  Fixing this found two bugs.

Cc: Luca Risolia <luca.risolia@studio.unibo.it>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Cc: linux-media@vger.kernel.org
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Showing 5 changed files with 8 additions and 5 deletions Side-by-side Diff

drivers/media/video/et61x251/et61x251_core.c
... ... @@ -76,8 +76,8 @@
76 76 "\none and for every other camera."
77 77 "\n");
78 78  
79   -static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
80   - ET61X251_FORCE_MUNMAP};
  79 +static bool force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
  80 + ET61X251_FORCE_MUNMAP};
81 81 module_param_array(force_munmap, bool, NULL, 0444);
82 82 MODULE_PARM_DESC(force_munmap,
83 83 "\n<0|1[,...]> Force the application to unmap previously"
drivers/media/video/sn9c102/sn9c102_core.c
... ... @@ -75,8 +75,8 @@
75 75 "\none and for every other camera."
76 76 "\n");
77 77  
78   -static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
79   - SN9C102_FORCE_MUNMAP};
  78 +static bool force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
  79 + SN9C102_FORCE_MUNMAP};
80 80 module_param_array(force_munmap, bool, NULL, 0444);
81 81 MODULE_PARM_DESC(force_munmap,
82 82 " <0|1[,...]>"
drivers/mfd/janz-cmodio.c
... ... @@ -33,7 +33,7 @@
33 33  
34 34 /* Module Parameters */
35 35 static unsigned int num_modules = CMODIO_MAX_MODULES;
36   -static unsigned char *modules[CMODIO_MAX_MODULES] = {
  36 +static char *modules[CMODIO_MAX_MODULES] = {
37 37 "empty", "empty", "empty", "empty",
38 38 };
39 39  
drivers/misc/lis3lv02d/lis3lv02d.c
... ... @@ -111,6 +111,8 @@
111 111 .get = param_get_int,
112 112 };
113 113  
  114 +#define param_check_axis(name, p) param_check_int(name, p)
  115 +
114 116 module_param_array_named(axes, lis3_dev.ac.as_array, axis, NULL, 0644);
115 117 MODULE_PARM_DESC(axes, "Axis-mapping for x,y,z directions");
116 118  
include/linux/moduleparam.h
... ... @@ -395,6 +395,7 @@
395 395 * module_param_named() for why this might be necessary.
396 396 */
397 397 #define module_param_array_named(name, array, type, nump, perm) \
  398 + param_check_##type(name, &(array)[0]); \
398 399 static const struct kparam_array __param_arr_##name \
399 400 = { .max = ARRAY_SIZE(array), .num = nump, \
400 401 .ops = &param_ops_##type, \