Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30322bcf authored by Vladimir Zapolskiy's avatar Vladimir Zapolskiy Committed by Linus Walleij
Browse files

gpiolib: don't dereference a desc before validation



The fix restores a proper validation of an input gpio desc, which
might be needed to deal with optional GPIOs correctly.

Fixes: 02e47980 ("gpio: Alter semantics of *raw* operations to actually be raw")
Signed-off-by: default avatarVladimir Zapolskiy <vz@mleia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent fe13862c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2437,7 +2437,7 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output_raw);
 */
int gpiod_direction_output(struct gpio_desc *desc, int value)
{
	struct gpio_chip *gc = desc->gdev->chip;
	struct gpio_chip *gc;
	int ret;

	VALIDATE_DESC(desc);
@@ -2454,6 +2454,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
		return -EIO;
	}

	gc = desc->gdev->chip;
	if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
		/* First see if we can enable open drain in hardware */
		ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc),