mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-22 00:42:01 +02:00
clk: fix an OF node reference leak in of_clk_get_parent_name()
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: 8da411cc19
("clk: let of_clk_get_parent_name() fail for invalid clock-indices")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20241210130913.3615205-1-joe@pf.is.s.u-tokyo.ac.jp
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
e5ca5d7b4d
commit
28fa3291ca
|
@ -5385,8 +5385,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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user