Add an error path to free the memory allocated by cx25821_alsa_dma_init(). Also move cx25821_alsa_dma_unmap() to the goto label to unify the error handling. Fixes: 8d8e6d6005de ("[media] cx28521: drop videobuf abuse in cx25821-alsa") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li --- drivers/media/pci/cx25821/cx25821-alsa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index f963ae79f685..1bf4fb96db1c 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c @@ -529,14 +529,13 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream, ret = cx25821_alsa_dma_map(chip); if (ret < 0) - goto error; + goto error_free; ret = cx25821_risc_databuffer_audio(chip->pci, &buf->risc, buf->sglist, chip->period_size, chip->num_periods, 1); if (ret < 0) { pr_info("DEBUG: ERROR after cx25821_risc_databuffer_audio()\n"); - cx25821_alsa_dma_unmap(chip); - goto error; + goto err_unmap; } /* Loop back to start of program */ @@ -550,6 +549,10 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream, return 0; +err_unmap: + cx25821_alsa_dma_unmap(chip); +error_free: + cx25821_alsa_dma_free(buf); error: chip->buf = NULL; kfree(buf); -- 2.25.1