diff options
| author | Bartosz Golaszewski <[email protected]> | 2025-02-10 10:51:59 +0000 |
|---|---|---|
| committer | Bartosz Golaszewski <[email protected]> | 2025-02-24 09:02:33 +0000 |
| commit | 74abd086d2ee5ef10f68848cfe39e271ac798685 (patch) | |
| tree | a30d3be1038fb77fe6014952d3559366b9e7bced /drivers/gpio/gpiolib.c | |
| parent | gpiolib: sanitize the return value of gpio_chip::get() (diff) | |
| download | kernel-74abd086d2ee5ef10f68848cfe39e271ac798685.tar.gz kernel-74abd086d2ee5ef10f68848cfe39e271ac798685.zip | |
gpiolib: sanitize the return value of gpio_chip::get_multiple()
As per the API contract, the get_multiple() callback is only allowed to
return 0 or a negative error number. Filter out anything else.
Reviewed-by: Linus Walleij <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Bartosz Golaszewski <[email protected]>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
| -rw-r--r-- | drivers/gpio/gpiolib.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 1a3f527aba0e..9ac2dad0ad34 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3182,10 +3182,16 @@ static int gpiod_get_raw_value_commit(const struct gpio_desc *desc) static int gpio_chip_get_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { + int ret; + lockdep_assert_held(&gc->gpiodev->srcu); - if (gc->get_multiple) - return gc->get_multiple(gc, mask, bits); + if (gc->get_multiple) { + ret = gc->get_multiple(gc, mask, bits); + if (ret > 0) + return -EBADE; + } + if (gc->get) { int i, value; |
