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;
On Wed 2020-10-28 13:04:02, Rohit Kumar wrote: > Thanks Pavel for the review. > > On 10/28/2020 12:32 PM, Pavel Machek wrote: > >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. > Yes, I will post the fix soon. Thanks for review. Well, the email had a fix attached :-). Feel free to review it and use it... Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index d07271ea4c451..2f29672477892 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -69,7 +69,7 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) int ret, dma_ch, dir = substream->stream; struct lpass_pcm_data *data; - data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -127,6 +127,7 @@ static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream) if (v->free_dma_channel) v->free_dma_channel(drvdata, data->dma_ch); + kfree(data); return 0; }