]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: imx: avoid memory leak
authorPeng Fan <peng.fan@nxp.com>
Wed, 4 Jan 2023 11:00:29 +0000 (19:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:21:51 +0000 (13:21 +0100)
[ Upstream commit f4419db4086e8c31821da14140e81498516a3c75 ]

In case imx_register_uart_clocks return early, the imx_uart_clocks
memory will be no freed. So execute kfree always to avoid memory leak.

Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20230104110032.1220721-2-peng.fan@oss.nxp.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/imx/clk.c

index 7cc669934253a210e300b5e9d597091e9a6b1897..d4cf0c7045ab27072be04c447ad0984ee7611490 100644 (file)
@@ -201,9 +201,10 @@ static int __init imx_clk_disable_uart(void)
                        clk_disable_unprepare(imx_uart_clocks[i]);
                        clk_put(imx_uart_clocks[i]);
                }
-               kfree(imx_uart_clocks);
        }
 
+       kfree(imx_uart_clocks);
+
        return 0;
 }
 late_initcall_sync(imx_clk_disable_uart);