[ALSA] Fix hang-up at disconnection of usb-audio
[firefly-linux-kernel-4.4.55.git] / sound / core / pcm_native.c
index 37b4b10850ae0358cdbbf654fffd6754aa5a11d4..66e24b5da4694dbaa40529a98b14743520aa41ef 100644 (file)
@@ -1310,7 +1310,8 @@ static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream,
                               int f_flags)
 {
        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;
        if (snd_pcm_running(substream))
                return -EBUSY;
@@ -1568,7 +1569,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
        runtime = substream->runtime;
        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;
 
        snd_power_lock(card);