]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels()
authorFelix Gu <ustc.gu@gmail.com>
Tue, 3 Feb 2026 14:07:58 +0000 (22:07 +0800)
committerAbel Vesa <abel.vesa@oss.qualcomm.com>
Thu, 19 Mar 2026 14:15:32 +0000 (16:15 +0200)
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@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20260203-clk-imx6q-v3-2-6cd2696bb371@gmail.com
Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
drivers/clk/imx/clk-imx6q.c

index 5549ef6c31173934a1ddad88a8fa59a24adc713f..35e6b59c01dbef430fce1349e77bf786c864f4cf 100644 (file)
@@ -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)