diff options
author | NeilBrown <neilb@suse.de> | 2012-04-01 20:19:30 +1000 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2012-04-18 18:40:10 +0530 |
commit | 4c06535c4b3900428e2a0d63f162b671bf134b86 (patch) | |
tree | f2a306312950e67954cf6dddd9ceb0318a502992 /drivers/char | |
parent | 0aff7661d16db7defe700699e258b5749d719424 (diff) |
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 <neilb@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/apm-emulation.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index 57501ca9204b..46118f845948 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c @@ -301,7 +301,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: |