From: Kautuk Consul Date: Tue, 19 Apr 2016 10:18:21 +0000 (+0530) Subject: powerpc: get_wchan(): solve possible race scenario due to parallel wakeup X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=4ca360f3dbf2036d964cdf3a6c4a45a81fdf8e18;p=openwrt%2Fstaging%2Fblogic.git powerpc: get_wchan(): solve possible race scenario due to parallel wakeup Add a check for p->state == TASK_RUNNING so that any wake-ups on task_struct p in the interim lead to 0 being returned by get_wchan(). Signed-off-by: Kautuk Consul [mpe: Confirmed other architectures do similar] Signed-off-by: Michael Ellerman --- diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index a0c74bbf3454..166145b18728 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1898,7 +1898,8 @@ unsigned long get_wchan(struct task_struct *p) do { sp = *(unsigned long *)sp; - if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD)) + if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) || + p->state == TASK_RUNNING) return 0; if (count > 0) { ip = ((unsigned long *)sp)[STACK_FRAME_LR_SAVE];