[PATCH] sched/core: Test online status in available_idle_cpu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The current implementation of available_idle_cpu() doesn't test
whether a possible cpu is offline. On s390 this dereferences a
NULL pointer in arch_vcpu_is_preempted() because lowcore is not
allocated for offline cpus. On x86, tracing also shows calls to
available_idle_cpu() after a cpu is disabled, but it looks like
this isn't causing any (obvious) issue. Nevertheless, add a check
and return early if the cpu isn't online.

Signed-off-by: Sven Schnelle <svens@xxxxxxxxxxxxx>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7019a40457a6..1d9b80411594 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7434,6 +7434,9 @@ int idle_cpu(int cpu)
  */
 int available_idle_cpu(int cpu)
 {
+	if (!cpu_online(cpu))
+		return 0;
+
 	if (!idle_cpu(cpu))
 		return 0;
 
-- 
2.40.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux