pinctrl: sunxi: Fix memory leak on krealloc failure
authorYuan Chen <chenyuan@kylinos.cn>
Fri, 20 Jun 2025 01:27:08 +0000 (09:27 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 24 Jun 2025 19:17:01 +0000 (21:17 +0200)
commite3507c56cbb208d4f160942748c527ef6a528ba1
tree9560f6c315b1c9e449504aa33c08b278fd48ad62
parentb4102e35243338d966f73ade1fec66d88e8f55ac
pinctrl: sunxi: Fix memory leak on krealloc failure

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@kylinos.cn>
Link: https://lore.kernel.org/20250620012708.16709-1-chenyuan_fl@163.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c