[PATCH v2] ASoC: SOF: Intel: Fix stream cleanup on pcm close

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Thu Mar 12 12:56:59 CET 2020



On 3/12/20 6:46 AM, Cezary Rojewski wrote:
> 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 close 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 at intel.com>
> ---
> 
> Changes in v2:
> - relocated stream->substream assignment from _pcm_close() to _hw_free()

nit-pick: both the commit title and message still refer to pcm close, 
maybe worth of a v3?

Sounds good otherwise so please add my

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>


>   sound/soc/sof/intel/hda-stream.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
> index 7daa913dbde0..5d386956906f 100644
> --- a/sound/soc/sof/intel/hda-stream.c
> +++ b/sound/soc/sof/intel/hda-stream.c
> @@ -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;
>   }
>   
> 


More information about the Alsa-devel mailing list