Skip to content

Commit

Permalink
gpiolib: don't dereference a desc before validation
Browse files Browse the repository at this point in the history
The fix restores a proper validation of an input gpio desc, which
might be needed to deal with optional GPIOs correctly.

Fixes: 02e4798 ("gpio: Alter semantics of *raw* operations to actually be raw")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Vladimir Zapolskiy authored and Linus Walleij committed Jan 2, 2018
1 parent fe13862 commit 30322bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down

0 comments on commit 30322bc

Please sign in to comment.