Skip to contentSkip to conversation

ASoC: SOF: Intel: Fix stream cleanup on pcm close

PATCH Superseded Cezary Rojewski 2 participants 2 messages Mar 12, 2020

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: SOF: Intel: Fix stream cleanup on pcm close

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")

---

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(+)
sound/soc/sof/intel/hda-stream.c +2 -0
index 7daa913dbde0..5d386956906f 100644
@@ -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;
 }
 
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines · Cezary Rojewski

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.

Quoted 6 lines
Fixes cdae3b9a47aa ("ASoC: SOF: Intel: Add Intel specific HDA PCM operations")

---

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

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