[PATCH v3 2/2] clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels()
Frank Li
Frank.li at nxp.com
Tue Feb 3 09:34:05 PST 2026
On Tue, Feb 03, 2026 at 10:07:58PM +0800, Felix Gu wrote:
> The function of_assigned_ldb_sels() calls of_parse_phandle_with_args()
> but never calls of_node_put() to release the reference, causing a memory
> leak.
>
> Fix this by adding proper cleanup calls on all exit paths.
>
> Fixes: 5d283b083800 ("clk: imx6: Fix procedure to switch the parent of LDB_DI_CLK")
> Signed-off-by: Felix Gu <ustc.gu at gmail.com>
> ---
Reviewed-by: Frank Li <Frank.Li at nxp.com>
> drivers/clk/imx/clk-imx6q.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
> index ba696cf34fe3..048e2ddba490 100644
> --- a/drivers/clk/imx/clk-imx6q.c
> +++ b/drivers/clk/imx/clk-imx6q.c
> @@ -188,9 +188,11 @@ static void of_assigned_ldb_sels(struct device_node *node,
> }
> if (clkspec.np != node || clkspec.args[0] >= IMX6QDL_CLK_END) {
> pr_err("ccm: parent clock %d not in ccm\n", index);
> + of_node_put(clkspec.np);
> return;
> }
> parent = clkspec.args[0];
> + of_node_put(clkspec.np);
>
> rc = of_parse_phandle_with_args(node, "assigned-clocks",
> "#clock-cells", index, &clkspec);
> @@ -198,9 +200,11 @@ static void of_assigned_ldb_sels(struct device_node *node,
> return;
> if (clkspec.np != node || clkspec.args[0] >= IMX6QDL_CLK_END) {
> pr_err("ccm: child clock %d not in ccm\n", index);
> + of_node_put(clkspec.np);
> return;
> }
> child = clkspec.args[0];
> + of_node_put(clkspec.np);
>
> if (child != IMX6QDL_CLK_LDB_DI0_SEL &&
> child != IMX6QDL_CLK_LDB_DI1_SEL)
>
> --
> 2.43.0
>
More information about the linux-arm-kernel
mailing list