OSDN Git Service

gpio: syscon: Fix possible NULL ptr usage
authorMarek Vasut <marex@denx.de>
Wed, 3 Oct 2018 22:52:52 +0000 (00:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 Nov 2019 13:44:37 +0000 (14:44 +0100)
[ Upstream commit 70728c29465bc4bfa7a8c14304771eab77e923c7 ]

The priv->data->set can be NULL while flags contains GPIO_SYSCON_FEAT_OUT
and chip->set is valid pointer. This happens in case the controller uses
the default GPIO setter. Always use chip->set to access the setter to avoid
possible NULL pointer dereferencing.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpio/gpio-syscon.c

index 7b25fdf..f579938 100644 (file)
@@ -127,7 +127,7 @@ static int syscon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int val)
                                   BIT(offs % SYSCON_REG_BITS));
        }
 
-       priv->data->set(chip, offset, val);
+       chip->set(chip, offset, val);
 
        return 0;
 }