Skip to content

Commit

Permalink
gpio: mockup: verify the number of GPIO chips requested
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bartosz Golaszewski authored and Linus Walleij committed Dec 2, 2017
1 parent 20c35ac commit b447a75
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpio/gpio-mockup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b447a75

Please sign in to comment.