Re: [PATCH 4.19 072/264] ASoC: qcom: lpass-platform: fix memory leak

Pavel Machek
2020-10-28T22:24:59Z

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

Hi!

> From: Rohit kumar <rohitkr@codeaurora.org>
>
> [ Upstream commit 5fd188215d4eb52703600d8986b22311099a5940 ]
>
> lpass_pcm_data is never freed. Free it in close
> ops to avoid memory leak.

AFAICT this introduces memory leaks in the error paths.

Best regards,
Pavel

Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 2f2967247789..9e13a00d8c80 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -81,17 +81,20 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
else
dma_ch = 0;

- if (dma_ch < 0)
+ if (dma_ch < 0) {
+ kfree(data);
return dma_ch;
+ }

drvdata->substream[dma_ch] = substream;

ret = regmap_write(drvdata->lpaif_map,
LPAIF_DMACTL_REG(v, dma_ch, dir), 0);
if (ret) {
+ kfree(data);
dev_err(soc_runtime->dev,
"error writing to rdmactl reg: %d\n", ret);
- return ret;
+ return ret;
}

data->dma_ch = dma_ch;
@@ -103,6 +106,7 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0) {
+ kfree(data);
dev_err(soc_runtime->dev, "setting constraints failed: %d\n",
ret);
return -EINVAL;

--
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]