diff mbox series

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

Message ID 20221208142635.1514944-1-cezary.rojewski@intel.com
State Accepted
Commit 084ca216931ab9313e6fb862c2ec9ec5e0702cd5
Headers show
Series ALSA: hda: Error out if invalid stream is being setup | expand

Commit Message

Cezary Rojewski Dec. 8, 2022, 2:26 p.m. UTC
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")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/hda/hdac_stream.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Takashi Iwai Dec. 9, 2022, 8:55 a.m. UTC | #1
On Thu, 08 Dec 2022 15:26:35 +0100,
Cezary Rojewski wrote:
> 
> 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")
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>

Thanks, pulled now.


Takashi
diff mbox series

Patch

diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index 8f625402505f..547adbc22590 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -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 */