]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gpio: mockup: refuse to accept an odd number of GPIO ranges
authorBartosz Golaszewski <brgl@bgdev.pl>
Fri, 9 Jun 2017 11:41:27 +0000 (13:41 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 20 Jun 2017 07:18:51 +0000 (09:18 +0200)
Currently we ignore the last odd range value, since each chip is
described by two values. Be more strict and require the user to
pass an even number of ranges.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mockup.c

index d78e8e081f5a3aa69f8e199dfc2c414a20e2ea1b..d95d37aeb91fde6eac5784d40351f971a07ad9fe 100644 (file)
@@ -334,7 +334,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
        int ret, i, base, ngpio;
        char *chip_name;
 
-       if (gpio_mockup_params_nr < 2)
+       if (gpio_mockup_params_nr < 2 || (gpio_mockup_params_nr % 2))
                return -EINVAL;
 
        chips = devm_kzalloc(dev,