Message ID | 20181003225252.21632-1-marex@denx.de |
---|---|
State | New |
Headers | show |
Series | gpio: syscon: Fix possible NULL ptr usage | expand |
On Thu, Oct 4, 2018 at 12:52 AM Marek Vasut <marex@denx.de> wrote: > 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> Patch applied. Yours, Linus Walleij
diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c index 87c18a544513..7f3da34c7874 100644 --- a/drivers/gpio/gpio-syscon.c +++ b/drivers/gpio/gpio-syscon.c @@ -122,7 +122,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; }
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> --- drivers/gpio/gpio-syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)