From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
"Simon Trimmer" <simont@opensource.cirrus.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
<patches@opensource.cirrus.com>, <linux-sound@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: wm_adsp: fix memleak in wm_adsp_buffer_populate
Date: Mon, 4 Dec 2023 10:26:01 +0000 [thread overview]
Message-ID: <a69e24fe-a4e6-4ae0-b27b-4d5c1f18e78a@opensource.cirrus.com> (raw)
In-Reply-To: <20231204074158.12026-1-dinghao.liu@zju.edu.cn>
On 04/12/2023 07:41, Dinghao Liu wrote:
> When wm_adsp_buffer_read() fails, we should free buf->regions.
> Otherwise, the callers of wm_adsp_buffer_populate() will
> directly free buf on failure, which makes buf->regions a leaked
> memory.
>
> Fixes: a792af69b08f ("ASoC: wm_adsp: Refactor compress stream initialisation")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> sound/soc/codecs/wm_adsp.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
> index 236b12b69ae5..c01e31175015 100644
> --- a/sound/soc/codecs/wm_adsp.c
> +++ b/sound/soc/codecs/wm_adsp.c
> @@ -1451,12 +1451,12 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
> ret = wm_adsp_buffer_read(buf, caps->region_defs[i].base_offset,
> ®ion->base_addr);
> if (ret < 0)
> - return ret;
> + goto err;
>
> ret = wm_adsp_buffer_read(buf, caps->region_defs[i].size_offset,
> &offset);
> if (ret < 0)
> - return ret;
> + goto err;
>
> region->cumulative_size = offset;
>
> @@ -1467,6 +1467,10 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
> }
>
> return 0;
> +
> +err:
> + kfree(buf->regions);
> + return ret;
> }
>
> static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf)
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
next prev parent reply other threads:[~2023-12-04 10:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 7:41 Dinghao Liu
2023-12-04 10:26 ` Richard Fitzgerald [this message]
2023-12-04 16:29 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a69e24fe-a4e6-4ae0-b27b-4d5c1f18e78a@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=dinghao.liu@zju.edu.cn \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=simont@opensource.cirrus.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®