[PATCH] pinctrl: stm32: Fix fwnode reference leak in stm32_gpiolib_register_bank()

Linus Walleij linusw at kernel.org
Tue Oct 13 16:37:31 PDT 2026


On Sun, Oct 11, 2026 at 8:17 AM Ma Ke <make_ruc2021 at 163.com> wrote:

> stm32_gpiolib_register_bank() walks the "gpio-ranges" property with
> fwnode_property_get_reference_args().  As documented in
> drivers/base/property.c:
>
>  * The caller is responsible for calling fwnode_handle_put() on the
>  * returned @args->fwnode pointer.
>
> The returned reference is never put.  The function calls the helper
> twice, once directly and then repeatedly in a while loop, and each
> call overwrites args, so only the last reference is even reachable
> and all the earlier ones are leaked for good.
>
> Put the reference as soon as args.args[] has been consumed, both for
> the initial call and for every iteration of the loop.
>
> Found by code review.
>
> Cc: stable at vger.kernel.org
> Fixes: bb949ed9b16b ("pinctrl: stm32: Switch to use for_each_gpiochip_node() helper")
> Signed-off-by: Ma Ke <make_ruc2021 at 163.com>

Patch applied as nonurgent fix, look into Andy's comment
and see if you can follow up with a thorough fix.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list