Skip to content

Commit c0f0253

Browse files
mssolarafaeljw
authored andcommitted
cpufreq: Avoid a bad reference count on CPU node
In the parse_perf_domain function, if the call to of_parse_phandle_with_args returns an error, then the reference to the CPU device node that was acquired at the start of the function would not be properly decremented. Address this by declaring the variable with the __free(device_node) cleanup attribute. Signed-off-by: Miquel Sabaté Solà <[email protected]> Acked-by: Viresh Kumar <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: All applicable <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8b4865c commit c0f0253

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

include/linux/cpufreq.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,20 +1107,16 @@ static inline int parse_perf_domain(int cpu, const char *list_name,
11071107
const char *cell_name,
11081108
struct of_phandle_args *args)
11091109
{
1110-
struct device_node *cpu_np;
11111110
int ret;
11121111

1113-
cpu_np = of_cpu_device_node_get(cpu);
1112+
struct device_node *cpu_np __free(device_node) = of_cpu_device_node_get(cpu);
11141113
if (!cpu_np)
11151114
return -ENODEV;
11161115

11171116
ret = of_parse_phandle_with_args(cpu_np, list_name, cell_name, 0,
11181117
args);
11191118
if (ret < 0)
11201119
return ret;
1121-
1122-
of_node_put(cpu_np);
1123-
11241120
return 0;
11251121
}
11261122

0 commit comments

Comments
 (0)