Skip to content

Commit f283d22

Browse files
neilbrownJiri Kosina
authored andcommitted
APM: fix deadlock in APM_IOC_SUSPEND ioctl
I found the Xorg server on my ARM device stuck in the 'msleep()' loop in apm_ioctl. I suspect it had attempted suspend immediately after resuming and lost a race. During that msleep(10);, a new suspend cycle must have started and changed ->suspend_state to SUSPEND_PENDING, so it was never seen to be SUSPEND_DONE and the loop could never exited. It would have moved on to SUSPEND_ACKTO but never been able to reach SUSPEND_DONE. So change the loop to only run while SUSPEND_ACKED rather than until SUSPEND_DONE. This is much safer. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b4a133d commit f283d22

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/apm-emulation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
302302
* anything critical, chill a bit on each iteration.
303303
*/
304304
while (wait_event_freezable(apm_suspend_waitqueue,
305-
as->suspend_state == SUSPEND_DONE))
305+
as->suspend_state != SUSPEND_ACKED))
306306
msleep(10);
307307
break;
308308
case SUSPEND_ACKTO:

0 commit comments

Comments
 (0)