diff mbox series

[4.4.y-cip] gpio: rcar: Avoid NULL pointer access in gpio_rcar_set_multiple()

Message ID 20200904074057.27932-1-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series [4.4.y-cip] gpio: rcar: Avoid NULL pointer access in gpio_rcar_set_multiple() | expand

Commit Message

Lad Prabhakar Sept. 4, 2020, 7:40 a.m. UTC
gpiochip_get_data() expects the controller probe to call
gpiochip_add_data() before using it, where as the rcar-gpio
driver probe has gpiochip_add() call thus resulting in NULL
pointer access.

Avoid this case by using gpio_to_priv() call.

Fixes: 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/gpio/gpio-rcar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pavel Machek Sept. 9, 2020, 7:02 a.m. UTC | #1
Hi!

> gpiochip_get_data() expects the controller probe to call
> gpiochip_add_data() before using it, where as the rcar-gpio
> driver probe has gpiochip_add() call thus resulting in NULL
> pointer access.
> 
> Avoid this case by using gpio_to_priv() call.
> 
> Fixes: 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")
> Signed-off-by: Lad Prabhakar

Thanks, applied and pushed out.

Best regards,
								Pavel
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index e829f11aca8f..2778dcd96ae7 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -352,7 +352,7 @@  static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
 static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
 				   unsigned long *bits)
 {
-	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
+	struct gpio_rcar_priv *p = gpio_to_priv(chip);
 	unsigned long flags;
 	u32 val, bankmask;