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@vger.kernel.org Signed-off-by: Haoxiang Li --- 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