aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cppc_cpufreq.c
diff options
context:
space:
mode:
authorChunyu Hu <chuhu@redhat.com>2018-03-05 00:40:38 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-03-20 05:52:31 -0400
commit55b55abc17f238c61921360e61dde90dd9a326d1 (patch)
treebe43429ef29ee5674a273b7f89f9abd54abc6332 /drivers/cpufreq/cppc_cpufreq.c
parentbf14721c97f39514267ed844b6d62036f76c3e51 (diff)
cpufreq: cppc_cpufreq: Fix cppc_cpufreq_init() failure path
Kmemleak reported the below leak. When cppc_cpufreq_init went into failure path, the cpu mask is not freed. After fix, this report is gone. And to avaoid potential NULL pointer reference, check the cpu value first. unreferenced object 0xffff800fd5ea4880 (size 128): comm "swapper/0", pid 1, jiffies 4294939510 (age 668.680s) hex dump (first 32 bytes): 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 .... ........... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffff0000082c4ae4>] __kmalloc_node+0x278/0x634 [<ffff0000088f4a74>] alloc_cpumask_var_node+0x28/0x60 [<ffff0000088f4af0>] zalloc_cpumask_var+0x14/0x1c [<ffff000008d20254>] cppc_cpufreq_init+0xd0/0x19c [<ffff000008083828>] do_one_initcall+0xec/0x15c [<ffff000008cd1018>] kernel_init_freeable+0x1f4/0x2a4 [<ffff0000089099b0>] kernel_init+0x18/0x10c [<ffff000008084d50>] ret_from_fork+0x10/0x18 [<ffffffffffffffff>] 0xffffffffffffffff Signed-off-by: Chunyu Hu <chuhu@redhat.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cppc_cpufreq.c')
-rw-r--r--drivers/cpufreq/cppc_cpufreq.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index a1c3025f9df7..8f7b21a4d537 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -230,8 +230,13 @@ static int __init cppc_cpufreq_init(void)
230 return ret; 230 return ret;
231 231
232out: 232out:
233 for_each_possible_cpu(i) 233 for_each_possible_cpu(i) {
234 kfree(all_cpu_data[i]); 234 cpu = all_cpu_data[i];
235 if (!cpu)
236 break;
237 free_cpumask_var(cpu->shared_cpu_map);
238 kfree(cpu);
239 }
235 240
236 kfree(all_cpu_data); 241 kfree(all_cpu_data);
237 return -ENODEV; 242 return -ENODEV;