From: Bartosz Golaszewski Date: Mon, 27 Nov 2017 10:48:39 +0000 (+0100) Subject: gpio: mockup: verify the number of GPIO chips requested X-Git-Tag: v4.16-rc1~135^2~70 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=b447a75100a63c114a8aaa02563088f4995c09f3;p=linux.git gpio: mockup: verify the number of GPIO chips requested 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 pair. Signed-off-by: Bartosz Golaszewski Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index b70f3b0c30b1..0a269cbe197c 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -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);