Commit 4ed31f20bb5bb90f003c91734c6b9d18169ae27e

Authored by Clemens Ladisch
1 parent e84d15f619

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 <clemens@ladisch.de>

Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff

sound/firewire/dice.c
... ... @@ -1000,12 +1000,15 @@
1000 1000 {
1001 1001 struct dice *dice = dev_get_drvdata(&unit->device);
1002 1002  
1003   - snd_card_disconnect(dice->card);
1004   -
1005 1003 mutex_lock(&dice->mutex);
  1004 +
1006 1005 amdtp_out_stream_pcm_abort(&dice->stream);
  1006 +
  1007 + snd_card_disconnect(dice->card);
  1008 +
1007 1009 dice_stream_stop(dice);
1008 1010 dice_owner_clear(dice);
  1011 +
1009 1012 mutex_unlock(&dice->mutex);
1010 1013  
1011 1014 snd_card_free_when_closed(dice->card);