This is a note to let you know that I've just added the patch titled clk: fix an OF node reference leak in of_clk_get_parent_name() to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: clk-fix-an-of-node-reference-leak-in-of_clk_get_pare.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 842b18dc3992f500072c9911888722af3fb3bb24 Author: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> Date: Tue Dec 10 22:09:12 2024 +0900 clk: fix an OF node reference leak in of_clk_get_parent_name() [ Upstream commit 28fa3291cad1c201967ef93edc6e7f8ccc9afbc0 ] Current implementation of of_clk_get_parent_name() leaks an OF node reference on error path. Add a of_node_put() call before returning an error. This bug was found by an experimental static analysis tool that I am developing. Fixes: 8da411cc1964 ("clk: let of_clk_get_parent_name() fail for invalid clock-indices") Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20241210130913.3615205-1-joe@xxxxxxxxxxxxxxxxxxxxx Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f795773b322a3..5bbd036f5295f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5343,8 +5343,10 @@ const char *of_clk_get_parent_name(const struct device_node *np, int index) count++; } /* We went off the end of 'clock-indices' without finding it */ - if (of_property_present(clkspec.np, "clock-indices") && !found) + if (of_property_present(clkspec.np, "clock-indices") && !found) { + of_node_put(clkspec.np); return NULL; + } if (of_property_read_string_index(clkspec.np, "clock-output-names", index,