[PATCH] media: cx88: Fix a potetial leak in snd_cx88_hw_params()
From: Haoxiang Li
Date: Sat Nov 21 2026 - 07:39:26 EST
Add an error path to free the memory allocated by cx88_alsa_dma_init().
Also move cx88_alsa_dma_unmap() to the goto label to unify the error
handling.
Fixes: b2c75abde0de ("[media] cx88: drop videobuf abuse in cx88-alsa")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
---
drivers/media/pci/cx88/cx88-alsa.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index d2534f90cfba..609409e259a9 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -479,14 +479,12 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
ret = cx88_alsa_dma_map(chip);
if (ret < 0)
- goto error;
+ goto error_free;
ret = cx88_risc_databuffer(chip->pci, &buf->risc, buf->sglist,
chip->period_size, chip->num_periods, 1);
- if (ret < 0) {
- cx88_alsa_dma_unmap(chip);
- goto error;
- }
+ if (ret < 0)
+ goto error_unmap;
/* Loop back to start of program */
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
@@ -497,6 +495,10 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream,
substream->runtime->dma_addr = 0;
return 0;
+error_unmap:
+ cx88_alsa_dma_unmap(chip);
+error_free:
+ cx88_alsa_dma_free(buf);
error:
kfree(buf);
return ret;
--
2.25.1