Skip to contentSkip to conversation

ALSA: hda: Error out if invalid stream is being setup

PATCH In review Cezary Rojewski 2 participants 2 messages Dec 8, 2022 – Dec 9, 2022 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda: Error out if invalid stream is being setup

Scenario when snd_hdac_stream_setup_periods() receives an instance of struct hdac_stream with neither ->substream nor ->cstream initialized is invalid.

Simultaneously addresses "uninitialized symbol 'dmab'" error reported by Smatch.

Fixes 3e9582267e3a ("ALSA: hda: Interrupt servicing and BDL setup for compress streams")
---
 sound/hda/hdac_stream.c | 3 +++
 1 file changed, 3 insertions(+)
sound/hda/hdac_stream.c +3 -0
index 8f625402505f..547adbc22590 100644
@@ -500,6 +500,9 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
 		dmab = snd_pcm_get_dma_buf(substream);
 	} else if (cstream) {
 		dmab = snd_pcm_get_dma_buf(cstream);
+	} else {
+		WARN(1, "No substream or cstream assigned\n");
+		return -EINVAL;
 	}
 
 	/* reset BDL address */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 10 lines · Cezary Rojewski

Scenario when snd_hdac_stream_setup_periods() receives an instance of struct hdac_stream with neither ->substream nor ->cstream initialized is invalid.

Simultaneously addresses "uninitialized symbol 'dmab'" error reported by Smatch.

Fixes 3e9582267e3a ("ALSA: hda: Interrupt servicing and BDL setup for compress streams")

Thanks, pulled now.

Takashi