ASoC: stm32: sai: fix stop management in isr
authorOlivier Moysan <olivier.moysan@st.com>
Thu, 19 Oct 2017 13:03:20 +0000 (15:03 +0200)
committerMark Brown <broonie@kernel.org>
Sat, 21 Oct 2017 10:15:34 +0000 (11:15 +0100)
Add check on substream validity.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/stm/stm32_sai_sub.c

index 90d43961389977f470a5c870d8678cdbd60a1cfe..5e66bf310351bf59be1aead622228206c7fad919 100644 (file)
@@ -184,7 +184,6 @@ static const struct regmap_config stm32_sai_sub_regmap_config_h7 = {
 static irqreturn_t stm32_sai_isr(int irq, void *devid)
 {
        struct stm32_sai_sub_data *sai = (struct stm32_sai_sub_data *)devid;
-       struct snd_pcm_substream *substream = sai->substream;
        struct platform_device *pdev = sai->pdev;
        unsigned int sr, imr, flags;
        snd_pcm_state_t status = SNDRV_PCM_STATE_RUNNING;
@@ -199,6 +198,11 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
        regmap_update_bits(sai->regmap, STM_SAI_CLRFR_REGX, SAI_XCLRFR_MASK,
                           SAI_XCLRFR_MASK);
 
+       if (!sai->substream) {
+               dev_err(&pdev->dev, "Device stopped. Spurious IRQ 0x%x\n", sr);
+               return IRQ_NONE;
+       }
+
        if (flags & SAI_XIMR_OVRUDRIE) {
                dev_err(&pdev->dev, "IRQ %s\n",
                        STM_SAI_IS_PLAYBACK(sai) ? "underrun" : "overrun");
@@ -227,9 +231,9 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
        }
 
        if (status != SNDRV_PCM_STATE_RUNNING) {
-               snd_pcm_stream_lock(substream);
-               snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-               snd_pcm_stream_unlock(substream);
+               snd_pcm_stream_lock(sai->substream);
+               snd_pcm_stop(sai->substream, SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock(sai->substream);
        }
 
        return IRQ_HANDLED;