From b4f6cd620b681af699aec58e36c6ae2a94c9a80d Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Wed, 3 Aug 2016 11:37:06 -0700 Subject: [PATCH] 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 --- drivers/soc/qcom/core_ctl_helper.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/core_ctl_helper.c b/drivers/soc/qcom/core_ctl_helper.c index 3dde30d29a1c..88201412128e 100644 --- a/drivers/soc/qcom/core_ctl_helper.c +++ b/drivers/soc/qcom/core_ctl_helper.c @@ -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); -- 2.11.0