ASoC: SOF: Intel: Fix stream cleanup on hw free
authorCezary Rojewski <cezary.rojewski@intel.com>
Thu, 12 Mar 2020 12:00:58 +0000 (13:00 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 12 Mar 2020 13:12:35 +0000 (13:12 +0000)
Field "substream" gets assigned during stream setup in
hda_dsp_pcm_hw_params() but it is never cleared afterwards during
cleanup procedure. Now, any non-pcm operation e.g.: compress can
mistakenly make use of that pointer as it's bypassing all
"if (s->substream)" checks.

Nulling the pointer during hw_free operation ensures no wild pointers
are left behind.

Fixes: cdae3b9a47aa ("ASoC: SOF: Intel: Add Intel specific HDA PCM operations")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200312120058.15057-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-stream.c

index c0ab9bb2a7978ca6ebd8de7f3382e9db60be9af0..d2234f802788aa7737cf30e6e5fb0004b9667555 100644 (file)
@@ -547,6 +547,8 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
                                        SOF_HDA_REG_PP_PPCTL, mask, 0);
        spin_unlock_irq(&bus->reg_lock);
 
+       stream->substream = NULL;
+
        return 0;
 }