ANDROID: drivers base/arch_topology: free cpumask cpus_to_visit
authorDietmar Eggemann <dietmar.eggemann@arm.com>
Tue, 13 Jun 2017 22:21:59 +0000 (23:21 +0100)
committerChris Redpath <chris.redpath@arm.com>
Thu, 14 Dec 2017 21:41:03 +0000 (21:41 +0000)
Free cpumask cpus_to_visit in case registering
init_cpu_capacity_notifier has failed or the parsing of the cpu
capacity-dmips-mhz property is done. The cpumask cpus_to_visit is
only used inside the notifier call init_cpu_capacity_callback.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Juri Lelli <juri.lelli@arm.com>
Reported-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Juri Lelli <juri.lelli@arm.com>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Change-Id: I84986964e6434d23a3c0feff2d9891516abcfe59
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
drivers/base/arch_topology.c

index 6df7d6676a48104267b5e739c6e58b85a00724e1..df2bab7de5dbff61542f74f6853249aa360ac41d 100644 (file)
@@ -212,6 +212,8 @@ static struct notifier_block init_cpu_capacity_notifier __initdata = {
 
 static int __init register_cpufreq_notifier(void)
 {
+       int ret;
+
        /*
         * on ACPI-based systems we need to use the default cpu capacity
         * until we have the necessary code to parse the cpu capacity, so
@@ -227,8 +229,13 @@ static int __init register_cpufreq_notifier(void)
 
        cpumask_copy(cpus_to_visit, cpu_possible_mask);
 
-       return cpufreq_register_notifier(&init_cpu_capacity_notifier,
-                                        CPUFREQ_POLICY_NOTIFIER);
+       ret = cpufreq_register_notifier(&init_cpu_capacity_notifier,
+                                       CPUFREQ_POLICY_NOTIFIER);
+
+       if (ret)
+               free_cpumask_var(cpus_to_visit);
+
+       return ret;
 }
 core_initcall(register_cpufreq_notifier);
 
@@ -236,6 +243,7 @@ static void __init parsing_done_workfn(struct work_struct *work)
 {
        cpufreq_unregister_notifier(&init_cpu_capacity_notifier,
                                         CPUFREQ_POLICY_NOTIFIER);
+       free_cpumask_var(cpus_to_visit);
 }
 
 #else