Re: [PATH v2] pinctrl: sunxi: Fix memory leak on krealloc failure in sunxi_pctrl_dt_node_to_map

From: Linus Walleij
Date: Tue Jun 24 2025 - 15:16:21 EST


On Fri, Jun 20, 2025 at 3:27 AM Yuan Chen <chenyuan_fl@xxxxxxx> wrote:

> From: Yuan Chen <chenyuan@xxxxxxxxxx>
>
> In sunxi_pctrl_dt_node_to_map(), when krealloc() fails to resize the pinctrl_map
> array, the function returns -ENOMEM directly without freeing the previously
> allocated *map buffer. This results in a memory leak of the original kmalloc_array
> allocation.
>
> Fixes: e11dee2e98f8 ("pinctrl: sunxi: Deal with configless pins")
> Signed-off-by: Yuan Chen <chenyuan@xxxxxxxxxx>

Patch applied for fixes!

Yours,
Linus Walleij