[PATCH] ALSA: hda/intel: fix memory leak in hda_init_streams()

From: Zhao Dongdong

Date: Mon Jul 06 2026 - 01:52:29 EST


From: Zhao Dongdong <zhaodongdong@xxxxxxxxxx>

In hda_init_streams(), if kzalloc_obj() fails at iteration i, the
previously allocated struct hda_intel_stream objects (0..i-1) are
not freed because they were already added to the bus stream_list
via azx_add_stream(). Returning -ENOMEM directly leaks them.

Call azx_free_streams() directly on allocation failure to release
all already-linked streams from the bus stream_list.

Fixes: e36a88b33cbe ("ALSA: hda: Move irq pending work into hda-intel stream")
Signed-off-by: Zhao Dongdong <zhaodongdong@xxxxxxxxxx>
---
sound/hda/controllers/intel.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/hda/controllers/intel.c b/sound/hda/controllers/intel.c
index 4b03c64e72ab..cf5783acf440 100644
--- a/sound/hda/controllers/intel.c
+++ b/sound/hda/controllers/intel.c
@@ -1866,8 +1866,10 @@ static int hda_init_streams(struct azx *chip)
struct hda_intel_stream *s = kzalloc_obj(*s);
int tag, dir;

- if (!s)
+ if (!s) {
+ azx_free_streams(chip);
return -ENOMEM;
+ }

s->hda = container_of(chip, struct hda_intel, chip);
INIT_WORK(&s->irq_pending_work, azx_irq_pending_work);
--
2.25.1