Skip to content

Commit 6282fba

Browse files
javiercarrascocruzvireshk
authored andcommitted
cpufreq: sun50i: fix memory leak in dt_has_supported_hw()
The for_each_child_of_node() loop does not decrement the child node refcount before the break instruction, even though the node is no longer required. This can be avoided with the new for_each_child_of_node_scoped() macro that removes the need for any of_node_put(). Fixes: fa5aec9 ("cpufreq: sun50i: Add support for opp_supported_hw") Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Andre Przywara <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 1613e60 commit 6282fba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cpufreq/sun50i-cpufreq-nvmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static const struct of_device_id cpu_opp_match_list[] = {
131131
static bool dt_has_supported_hw(void)
132132
{
133133
bool has_opp_supported_hw = false;
134-
struct device_node *np, *opp;
134+
struct device_node *np;
135135
struct device *cpu_dev;
136136

137137
cpu_dev = get_cpu_device(0);
@@ -142,7 +142,7 @@ static bool dt_has_supported_hw(void)
142142
if (!np)
143143
return false;
144144

145-
for_each_child_of_node(np, opp) {
145+
for_each_child_of_node_scoped(np, opp) {
146146
if (of_find_property(opp, "opp-supported-hw", NULL)) {
147147
has_opp_supported_hw = true;
148148
break;

0 commit comments

Comments
 (0)