From 4ed31f20bb5bb90f003c91734c6b9d18169ae27e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 4 Sep 2011 22:13:09 +0200 Subject: [PATCH] ALSA: dice: fix hang when unplugging a running device When aborting a PCM stream, the xrun is signaled only if the stream is running. When disconnecting a PCM stream, calling snd_card_disconnect() too early would change the stream into a non-running state and thus prevent the xrun from being noticed by user space. To prevent this, move the snd_card_disconnect() call after the xrun. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c index 63446f86cdd7..d0575a96ea70 100644 --- a/sound/firewire/dice.c +++ b/sound/firewire/dice.c @@ -1000,12 +1000,15 @@ static void dice_remove(struct fw_unit *unit) { struct dice *dice = dev_get_drvdata(&unit->device); + mutex_lock(&dice->mutex); + + amdtp_out_stream_pcm_abort(&dice->stream); + snd_card_disconnect(dice->card); - mutex_lock(&dice->mutex); - amdtp_out_stream_pcm_abort(&dice->stream); dice_stream_stop(dice); dice_owner_clear(dice); + mutex_unlock(&dice->mutex); snd_card_free_when_closed(dice->card);