alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: SOF: Intel: Fix stream cleanup on pcm close
@ 2020-03-12 11:46 Cezary Rojewski
  2020-03-12 11:56 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 2+ messages in thread
From: Cezary Rojewski @ 2020-03-12 11:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: lgirdwood, Cezary Rojewski, broonie, tiwai, pierre-louis.bossart

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@intel.com>
---

Changes in v2:
- relocated stream->substream assignment from _pcm_close() to _hw_free()


 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;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ASoC: SOF: Intel: Fix stream cleanup on pcm close
  2020-03-12 11:46 [PATCH v2] ASoC: SOF: Intel: Fix stream cleanup on pcm close Cezary Rojewski
@ 2020-03-12 11:56 ` Pierre-Louis Bossart
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Louis Bossart @ 2020-03-12 11:56 UTC (permalink / raw)
  To: Cezary Rojewski, alsa-devel; +Cc: broonie, lgirdwood, tiwai



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@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@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;
>   }
>   
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-12 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 11:46 [PATCH v2] ASoC: SOF: Intel: Fix stream cleanup on pcm close Cezary Rojewski
2020-03-12 11:56 ` Pierre-Louis Bossart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).