Skip to content

Commit 01121e3

Browse files
Yuuoniygregkh
authored andcommitted
PM / devfreq: exynos-ppmu: Fix refcount leak in of_get_devfreq_events
commit f44b799 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7cf7ed8 commit 01121e3

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
@@ -514,15 +514,19 @@ static int of_get_devfreq_events(struct device_node *np,
514514

515515
count = of_get_child_count(events_np);
516516
desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
517-
if (!desc)
517+
if (!desc) {
518+
of_node_put(events_np);
518519
return -ENOMEM;
520+
}
519521
info->num_events = count;
520522

521523
of_id = of_match_device(exynos_ppmu_id_match, dev);
522524
if (of_id)
523525
info->ppmu_type = (enum exynos_ppmu_type)of_id->data;
524-
else
526+
else {
527+
of_node_put(events_np);
525528
return -EINVAL;
529+
}
526530

527531
j = 0;
528532
for_each_child_of_node(events_np, node) {

0 commit comments

Comments
 (0)