arm-cci: fix handling cpumask_any_but return value
authorAndrzej Hajda <a.hajda@samsung.com>
Tue, 23 Feb 2016 10:49:44 +0000 (10:49 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 29 Feb 2016 23:23:16 +0000 (23:23 +0000)
cpumask_any_but returns value >= nr_cpu_ids if there are no more CPUs.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/bus/arm-cci.c

index ee47e6b..5fb1c06 100644 (file)
@@ -1270,7 +1270,7 @@ static int cci_pmu_cpu_notifier(struct notifier_block *self,
                if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus))
                        break;
                target = cpumask_any_but(cpu_online_mask, cpu);
-               if (target < 0) // UP, last CPU
+               if (target >= nr_cpu_ids) // UP, last CPU
                        break;
                /*
                 * TODO: migrate context once core races on event->ctx have