Skip to content

Commit f44b799

Browse files
Yuuoniychanwoochoi
authored andcommitted
PM / devfreq: exynos-ppmu: Fix refcount leak in of_get_devfreq_events
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. This function only calls of_node_put() in normal path, missing it in error paths. Add missing of_node_put() to avoid refcount leak. Fixes: f262f28 ("PM / devfreq: event: Add devfreq_event class") Signed-off-by: Miaoqian Lin <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 20e6c3c commit f44b799

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/devfreq/event/exynos-ppmu.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,19 @@ static int of_get_devfreq_events(struct device_node *np,
519519

520520
count = of_get_child_count(events_np);
521521
desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
522-
if (!desc)
522+
if (!desc) {
523+
of_node_put(events_np);
523524
return -ENOMEM;
525+
}
524526
info->num_events = count;
525527

526528
of_id = of_match_device(exynos_ppmu_id_match, dev);
527529
if (of_id)
528530
info->ppmu_type = (enum exynos_ppmu_type)of_id->data;
529-
else
531+
else {
532+
of_node_put(events_np);
530533
return -EINVAL;
534+
}
531535

532536
j = 0;
533537
for_each_child_of_node(events_np, node) {

0 commit comments

Comments
 (0)