cpufreq: qcom-hw: Remove kfree() and unmap_base/release_region labels

Remove unmap_base/release_region labels to avoid kernel crash when
there is no cpufreq hardware data available and explicit kfree() and
iounmap() not required since they are dev managed.

 Trying to vfree() nonexistent vm area ((____ptrval____))
 WARNING: CPU: 3 PID: 90 at mm/vmalloc.c:2608 __vunmap+0x9c/0x2a8
 Modules linked in:
 CPU:3 PID:90 Comm:kworker/u8:1 Tainted: G W 5.15.20-ge6916696ed47-dirty #1
 Hardware name: Qualcomm Technologies, Inc. Cinder RU RUMI (DT)
 Workqueue: events_unbound deferred_probe_work_func
 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : __vunmap+0x9c/0x2a8
 lr : __vunmap+0x9c/0x2a8
 Call trace:
  __vunmap+0x9c/0x2a8
  vunmap+0x64/0x7c
  iounmap+0x2c/0x40
  devm_ioremap_release+0x18/0x28
  devres_release_all+0xd0/0x19c
  really_probe+0xfc/0x354
  __driver_probe_device+0x11c/0x184
  driver_probe_device+0x4c/0x18c

 kernel crash at mm/slub.c:363!
 Modules linked in:
 CPU:0 PID:7 Comm:kworker/u8:0 Tainted: G W 5.15.20-ge6916696ed47-dirty #1
 Hardware name: Qualcomm Technologies, Inc. Cinder RU RUMI (DT)
 Workqueue: events_unbound deferred_probe_work_func
 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : kfree+0x31c/0x38c
 lr : kfree+0x108/0x38c
 Call trace:
  kfree+0x31c/0x38c
  qcom_cpufreq_hw_cpu_init+0x340/0x408
  cpufreq_online+0x300/0x80c
  cpufreq_add_dev+0x48/0xb8
  subsys_interface_register+0xe4/0x140
  cpufreq_register_driver+0x174/0x2c8
  qcom_cpufreq_hw_driver_probe+0x144/0x1b4
  platform_probe+0xb0/0xd8

Change-Id: I75e0d40d6aa68f541cc87393e9bbef2628c1cf96
Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
This commit is contained in:
Imran Shaik 2022-04-21 11:05:38 +05:30 committed by Mike Tipton
parent 48acc4c519
commit 263dd3f6ce

View File

@ -602,14 +602,12 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
base = devm_ioremap(dev, res->start, resource_size(res));
if (!base) {
dev_err(dev, "failed to map resource %pR\n", res);
ret = -ENOMEM;
goto release_region;
return -ENOMEM;
}
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data) {
ret = -ENOMEM;
goto unmap_base;
return -ENOMEM;
}
data->soc_data = of_device_get_match_data(&pdev->dev);
@ -664,12 +662,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
return 0;
error:
kfree(data);
policy->driver_data = NULL;
unmap_base:
iounmap(base);
release_region:
release_mem_region(res->start, resource_size(res));
return ret;
}