Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f553912 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/sysdev/simple_gpio: Fix oops in gpio save_regs function



of_mm_gpiochip_add_data() generates an oops for NULL pointer dereference.

of_mm_gpiochip_add_data() calls mm_gc->save_regs() before
setting the data, therefore ->save_regs() cannot use gpiochip_get_data()

Fixes: 937daafc ("powerpc: simple-gpio: use gpiochip data pointer")
Cc: stable@vger.kernel.org # v4.7+
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 99acc9be
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -75,7 +75,8 @@ static int u8_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)

static void u8_gpio_save_regs(struct of_mm_gpio_chip *mm_gc)
{
	struct u8_gpio_chip *u8_gc = gpiochip_get_data(&mm_gc->gc);
	struct u8_gpio_chip *u8_gc =
		container_of(mm_gc, struct u8_gpio_chip, mm_gc);

	u8_gc->data = in_8(mm_gc->regs);
}