Skip to content

Commit ad2fab3

Browse files
matnymanlinusw
authored andcommitted
gpiolib: Don't return -EPROBE_DEFER to sysfs, or for invalid gpios
gpios requested with invalid numbers, or gpios requested from userspace via sysfs should not try to be deferred on failure. Cc: stable@kernel.org Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent c57d75c commit ad2fab3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,11 @@ static ssize_t export_store(struct class *class,
623623
*/
624624

625625
status = gpio_request(gpio, "sysfs");
626-
if (status < 0)
626+
if (status < 0) {
627+
if (status == -EPROBE_DEFER)
628+
status = -ENODEV;
627629
goto done;
628-
630+
}
629631
status = gpio_export(gpio, true);
630632
if (status < 0)
631633
gpio_free(gpio);
@@ -1191,8 +1193,10 @@ int gpio_request(unsigned gpio, const char *label)
11911193

11921194
spin_lock_irqsave(&gpio_lock, flags);
11931195

1194-
if (!gpio_is_valid(gpio))
1196+
if (!gpio_is_valid(gpio)) {
1197+
status = -EINVAL;
11951198
goto done;
1199+
}
11961200
desc = &gpio_desc[gpio];
11971201
chip = desc->chip;
11981202
if (chip == NULL)

0 commit comments

Comments
 (0)