]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gpio: mockup: verify the number of GPIO chips requested
authorBartosz Golaszewski <brgl@bgdev.pl>
Mon, 27 Nov 2017 10:48:39 +0000 (11:48 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 2 Dec 2017 21:42:24 +0000 (22:42 +0100)
The number of supported mockup chips is limited. Check this limit when
parsing the module parameters.

Also: make sure that each chip is described with a <base - ngpio> pair.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mockup.c

index b70f3b0c30b1d9e42a8017dbb16fb30223eee91b..0a269cbe197cfd7085e4bedcc62dc5c145d31c8a 100644 (file)
@@ -330,7 +330,9 @@ static int __init gpio_mockup_init(void)
 {
        int err;
 
-       if (gpio_mockup_params_nr < 2 || (gpio_mockup_params_nr % 2))
+       if ((gpio_mockup_params_nr < 2) ||
+           (gpio_mockup_params_nr % 2) ||
+           (gpio_mockup_params_nr > GPIO_MOCKUP_MAX_RANGES))
                return -EINVAL;
 
        gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup-event", NULL);