diff options
author | Bartosz Golaszewski <brgl@bgdev.pl> | 2017-11-27 11:48:49 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-12-02 22:42:28 +0100 |
commit | fa86963a7546e08efdb32153522c1a42de069c8b (patch) | |
tree | 406ed558fb99f99a7449b5f8a5ad43985410ff14 /drivers/gpio/gpio-mockup.c | |
parent | 46526c15cadcba43c69e22a6dfaf3f6f444c70aa (diff) | |
download | linux-stable-fa86963a7546e08efdb32153522c1a42de069c8b.tar.gz linux-stable-fa86963a7546e08efdb32153522c1a42de069c8b.tar.bz2 linux-stable-fa86963a7546e08efdb32153522c1a42de069c8b.zip |
gpio: mockup: verify that ngpio > 0
Improve the module params sanitization: bail out from init if the user
tries to pass a non-positive number of GPIO lines for any mockup chip.
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-mockup.c')
-rw-r--r-- | drivers/gpio/gpio-mockup.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 68a0c1e06a16..532f5807390b 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -335,6 +335,15 @@ static int __init gpio_mockup_init(void) /* Each chip is described by two values. */ num_chips = gpio_mockup_params_nr / 2; + /* + * The second value in the <base GPIO - number of GPIOS> pair must + * always be greater than 0. + */ + for (i = 0; i < num_chips; i++) { + if (gpio_mockup_ranges[i * 2 + 1] < 0) + return -EINVAL; + } + gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup-event", NULL); if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) gpio_mockup_err("error creating debugfs directory\n"); |