aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vz@mleia.com>2017-12-21 18:37:24 +0200
committerLinus Walleij <linus.walleij@linaro.org>2018-01-02 09:31:20 +0100
commit30322bcf82d74cad0d6e1cf9ba7fa7fa48c7a026 (patch)
treef46a497daef538e4bce3a9491db6dedbb9a1e8bf /drivers/gpio
parentgpio: fix aspeed_gpio_banks array size check (diff)
downloadlinux-dev-30322bcf82d74cad0d6e1cf9ba7fa7fa48c7a026.tar.xz
linux-dev-30322bcf82d74cad0d6e1cf9ba7fa7fa48c7a026.zip
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: 02e479808b5d ("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>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 0ae49943dfaf..02cf658eeedd 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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),