msm_performance: Add NULL pointer checks

Add NULL pointer checks.

Change-Id: Ia49ed015e8ea13c63296c4491c9d3af99ef0e121
Signed-off-by: Shashi Shekar Shankar <ssbang@codeaurora.org>
This commit is contained in:
Shashi Shekar Shankar 2018-03-27 13:41:06 +05:30 committed by Gerrit - the friendly Code Review server
parent 6d0d8f7af3
commit 98d3b2cf3b

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -2379,6 +2379,7 @@ end:
static void __ref try_hotplug(struct cluster *data)
{
unsigned int i;
struct device *dev;
if (!clusters_inited)
return;
@ -2405,7 +2406,8 @@ static void __ref try_hotplug(struct cluster *data)
pr_debug("msm_perf: Offlining CPU%d\n", i);
cpumask_set_cpu(i, data->offlined_cpus);
lock_device_hotplug();
if (device_offline(get_cpu_device(i))) {
dev = get_cpu_device(i);
if (!dev || device_offline(dev)) {
cpumask_clear_cpu(i, data->offlined_cpus);
pr_debug("msm_perf: Offlining CPU%d failed\n",
i);
@ -2423,7 +2425,8 @@ static void __ref try_hotplug(struct cluster *data)
continue;
pr_debug("msm_perf: Onlining CPU%d\n", i);
lock_device_hotplug();
if (device_online(get_cpu_device(i))) {
dev = get_cpu_device(i);
if (!dev || device_online(dev)) {
pr_debug("msm_perf: Onlining CPU%d failed\n",
i);
unlock_device_hotplug();
@ -2442,11 +2445,19 @@ static void __ref try_hotplug(struct cluster *data)
static void __ref release_cluster_control(struct cpumask *off_cpus)
{
int cpu;
struct device *dev;
for_each_cpu(cpu, off_cpus) {
pr_debug("msm_perf: Release CPU %d\n", cpu);
lock_device_hotplug();
if (!device_online(get_cpu_device(cpu)))
dev = get_cpu_device(cpu);
if (!dev) {
pr_debug("msm_perf: Failed to get CPU%d\n",
cpu);
unlock_device_hotplug();
continue;
}
if (!device_online(dev))
cpumask_clear_cpu(cpu, off_cpus);
unlock_device_hotplug();
}