Skip to content

Commit

Permalink
PM / devfreq: exynos-ppmu: Fix refcount leak in of_get_devfreq_events
Browse files Browse the repository at this point in the history
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 <linmq006@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Yuuoniy authored and gregkh committed Jul 7, 2022
1 parent 653bdcd commit e65027f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/devfreq/event/exynos-ppmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,19 @@ static int of_get_devfreq_events(struct device_node *np,

count = of_get_child_count(events_np);
desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
if (!desc)
if (!desc) {
of_node_put(events_np);
return -ENOMEM;
}
info->num_events = count;

of_id = of_match_device(exynos_ppmu_id_match, dev);
if (of_id)
info->ppmu_type = (enum exynos_ppmu_type)of_id->data;
else
else {
of_node_put(events_np);
return -EINVAL;
}

j = 0;
for_each_child_of_node(events_np, node) {
Expand Down

0 comments on commit e65027f

Please sign in to comment.