soc: qcom: core_ctl: Fix possible null-pointer dereference

Ensure we don't try to call online/offline functions with a
null-pointer.

CRs-fixed: 1049957
Change-Id: I6fa8f9bde5d5fd0680b5c571ba3cc99bd1f508b1
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
This commit is contained in:
Olav Haugan 2016-08-03 11:37:06 -07:00
parent 60aacdb787
commit b4f6cd620b

View file

@ -72,22 +72,28 @@ EXPORT_SYMBOL(core_ctl_find_cpu_device);
int __ref core_ctl_online_core(unsigned int cpu)
{
int ret;
int ret = -EINVAL;
struct device *dev = get_cpu_device(cpu);
lock_device_hotplug();
ret = device_online(get_cpu_device(cpu));
unlock_device_hotplug();
if (dev) {
lock_device_hotplug();
ret = device_online(dev);
unlock_device_hotplug();
}
return ret;
}
EXPORT_SYMBOL(core_ctl_online_core);
int __ref core_ctl_offline_core(unsigned int cpu)
{
int ret;
int ret = -EINVAL;
struct device *dev = get_cpu_device(cpu);
lock_device_hotplug();
ret = device_offline(get_cpu_device(cpu));
unlock_device_hotplug();
if (dev) {
lock_device_hotplug();
ret = device_offline(dev);
unlock_device_hotplug();
}
return ret;
}
EXPORT_SYMBOL(core_ctl_offline_core);