module_param: check type correctness for module_param_array
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 12 Jan 2012 23:02:16 +0000 (09:32 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 12 Jan 2012 23:02:16 +0000 (09:32 +1030)
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>
drivers/media/video/et61x251/et61x251_core.c
drivers/media/video/sn9c102/sn9c102_core.c
drivers/mfd/janz-cmodio.c
drivers/misc/lis3lv02d/lis3lv02d.c
include/linux/moduleparam.h

index 40f214ab924f718f68146dbf150ff119cb40c2ca..5539f09440ac7eae5ae1ce8c67ef9509b85ef73b 100644 (file)
@@ -76,8 +76,8 @@ MODULE_PARM_DESC(video_nr,
                 "\none and for every other camera."
                 "\n");
 
-static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
-                              ET61X251_FORCE_MUNMAP};
+static bool force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
+                             ET61X251_FORCE_MUNMAP};
 module_param_array(force_munmap, bool, NULL, 0444);
 MODULE_PARM_DESC(force_munmap,
                 "\n<0|1[,...]> Force the application to unmap previously"
index 7025be1292864d951607d823b74f1f3c777c08a9..c2882fa5be85f3d0a3eda99648b806860f1b0db9 100644 (file)
@@ -75,8 +75,8 @@ MODULE_PARM_DESC(video_nr,
                 "\none and for every other camera."
                 "\n");
 
-static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
-                              SN9C102_FORCE_MUNMAP};
+static bool force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
+                             SN9C102_FORCE_MUNMAP};
 module_param_array(force_munmap, bool, NULL, 0444);
 MODULE_PARM_DESC(force_munmap,
                 " <0|1[,...]>"
index 5c2a06acb77fce5d226c183e2197602eff8f434d..a9223ed1b7c5d9a152a8533c72ac1faafd3b7385 100644 (file)
@@ -33,7 +33,7 @@
 
 /* Module Parameters */
 static unsigned int num_modules = CMODIO_MAX_MODULES;
-static unsigned char *modules[CMODIO_MAX_MODULES] = {
+static char *modules[CMODIO_MAX_MODULES] = {
        "empty", "empty", "empty", "empty",
 };
 
index 29d12a70eb1bcbb2ccb08ab76f907057ee368021..a981e2a42f92a9427058d528fd784ed2798c6883 100644 (file)
@@ -111,6 +111,8 @@ static struct kernel_param_ops param_ops_axis = {
        .get = param_get_int,
 };
 
+#define param_check_axis(name, p) param_check_int(name, p)
+
 module_param_array_named(axes, lis3_dev.ac.as_array, axis, NULL, 0644);
 MODULE_PARM_DESC(axes, "Axis-mapping for x,y,z directions");
 
index 7939f636c8bae3c747b604c98472d34de620ab70..794d4b0f12154b29e04440080d59e6d2a2f3e275 100644 (file)
@@ -395,6 +395,7 @@ extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
  * module_param_named() for why this might be necessary.
  */
 #define module_param_array_named(name, array, type, nump, perm)                \
+       param_check_##type(name, &(array)[0]);                          \
        static const struct kparam_array __param_arr_##name             \
        = { .max = ARRAY_SIZE(array), .num = nump,                      \
            .ops = &param_ops_##type,                                   \