mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-26 13:47:26 +00:00
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 <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250210-gpio-sanitize-retvals-v1-5-12ea88506cb2@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
86ef402d80
commit
74abd086d2
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user