Commit de1b8b93 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Fix hang-up at disconnection of usb-audio

Fix hang-up at disconnection of usb-audio devices while accessing PCM.
Don't handle PCM operations any more after shutdown flag is set.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 282e0c87
...@@ -2359,7 +2359,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) ...@@ -2359,7 +2359,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
snd_assert(substream != NULL, return -ENXIO); snd_assert(substream != NULL, return -ENXIO);
pcm = substream->pcm; pcm = substream->pcm;
snd_pcm_oss_sync(pcm_oss_file); if (!pcm->card->shutdown)
snd_pcm_oss_sync(pcm_oss_file);
mutex_lock(&pcm->open_mutex); mutex_lock(&pcm->open_mutex);
snd_pcm_oss_release_file(pcm_oss_file); snd_pcm_oss_release_file(pcm_oss_file);
mutex_unlock(&pcm->open_mutex); mutex_unlock(&pcm->open_mutex);
......
...@@ -1310,7 +1310,8 @@ static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, ...@@ -1310,7 +1310,8 @@ static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream,
int f_flags) int f_flags)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
if (runtime->status->state == SNDRV_PCM_STATE_OPEN) if (runtime->status->state == SNDRV_PCM_STATE_OPEN ||
runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED)
return -EBADFD; return -EBADFD;
if (snd_pcm_running(substream)) if (snd_pcm_running(substream))
return -EBUSY; return -EBUSY;
...@@ -1568,7 +1569,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) ...@@ -1568,7 +1569,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
runtime = substream->runtime; runtime = substream->runtime;
card = substream->pcm->card; card = substream->pcm->card;
if (runtime->status->state == SNDRV_PCM_STATE_OPEN) if (runtime->status->state == SNDRV_PCM_STATE_OPEN ||
runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED)
return -EBADFD; return -EBADFD;
snd_power_lock(card); snd_power_lock(card);
......
...@@ -1469,7 +1469,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) ...@@ -1469,7 +1469,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
subs->cur_audiofmt = NULL; subs->cur_audiofmt = NULL;
subs->cur_rate = 0; subs->cur_rate = 0;
subs->period_bytes = 0; subs->period_bytes = 0;
release_substream_urbs(subs, 0); if (!subs->stream->chip->shutdown)
release_substream_urbs(subs, 0);
return snd_pcm_free_vmalloc_buffer(substream); return snd_pcm_free_vmalloc_buffer(substream);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment