Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: f262f28c1470 ("PM / devfreq: event: Add devfreq_event class")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Miaoqian Lin and committed by
Chanwoo Choi
f44b7996 20e6c3cc

+6 -2
+6 -2
drivers/devfreq/event/exynos-ppmu.c
··· 519 519 520 520 count = of_get_child_count(events_np); 521 521 desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL); 522 - if (!desc) 522 + if (!desc) { 523 + of_node_put(events_np); 523 524 return -ENOMEM; 525 + } 524 526 info->num_events = count; 525 527 526 528 of_id = of_match_device(exynos_ppmu_id_match, dev); 527 529 if (of_id) 528 530 info->ppmu_type = (enum exynos_ppmu_type)of_id->data; 529 - else 531 + else { 532 + of_node_put(events_np); 530 533 return -EINVAL; 534 + } 531 535 532 536 j = 0; 533 537 for_each_child_of_node(events_np, node) {