]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
PM / devfreq: exynos-ppmu: Fix refcount leak in of_get_devfreq_events
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 26 May 2022 08:28:56 +0000 (12:28 +0400)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:54:15 +0000 (10:54 +0200)
BugLink: https://bugs.launchpad.net/bugs/1986728
commit f44b799603a9b5d2e375b0b2d54dd0b791eddfc2 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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/devfreq/event/exynos-ppmu.c

index 17ed980d9099861229ec780c9a7ea68567d0e54d..d6da9c3e310673cabd5fa6283155d8000dd57097 100644 (file)
@@ -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) {