[PATCH v7 1/5] pinctrl: mediatek: use devm_gpiochip_add_data() for GPIO chip

Linus Walleij linusw at kernel.org
Wed Sep 16 09:35:18 PDT 2026


On Thu, Jul 23, 2026 at 5:58 AM Justin Yeh <justin.yeh at mediatek.com> wrote:

> The gpio_chip is allocated with device-managed memory but registered with
> the non-managed gpiochip_add_data(). This was harmless while the drivers
> were built-in, but once they can be built as modules and unbound/rmmod'd,
> devm frees the gpio_chip's memory while it is still registered, causing a
> use-after-free.
>
> Register it with devm_gpiochip_add_data() so it shares the same
> device-managed lifecycle, which also lets the manual gpiochip_remove()
> error paths go away.
>
> Fixes: a6df410d420a ("pinctrl: mediatek: Add Pinctrl/GPIO driver for mt8135.")
> Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings")
> Fixes: e78d57b2f87c ("pinctrl: mediatek: add pinctrl-moore that implements the generic pinctrl dt-bindings")
> Signed-off-by: Justin Yeh <justin.yeh at mediatek.com>
> Reviewed-by: Chen-Yu Tsai <wenst at chromium.org>

This patch does not apply to current v7.3-rc1.
Please rebase and resend!

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list