Skip to content

Commit

Permalink
APM: fix deadlock in APM_IOC_SUSPEND ioctl
Browse files Browse the repository at this point in the history
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 <neilb@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
NeilBrown authored and Jiri Kosina committed Apr 3, 2012
1 parent b4a133d commit f283d22
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/apm-emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
* anything critical, chill a bit on each iteration.
*/
while (wait_event_freezable(apm_suspend_waitqueue,
as->suspend_state == SUSPEND_DONE))
as->suspend_state != SUSPEND_ACKED))
msleep(10);
break;
case SUSPEND_ACKTO:
Expand Down

0 comments on commit f283d22

Please sign in to comment.