From: Takashi Iwai <tiwai@suse.de>
To: Jianglei Nie <niejianglei2021@163.com>
Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda/ca0132: fix potential memory leak in dspxfr_image()
Date: Wed, 07 Sep 2022 09:35:08 +0200 [thread overview]
Message-ID: <87illzeixf.wl-tiwai@suse.de> (raw)
In-Reply-To: <20220907065917.55810-1-niejianglei2021@163.com>
On Wed, 07 Sep 2022 08:59:17 +0200,
Jianglei Nie wrote:
>
> dspxfr_image() allocates DSP ports for the download stream with
> dsp_allocate_ports_format(). When gets some error, the allocated
> DSP ports are not released, which will lead to a memory leak.
Hmm, those allocate_* functions don't really allocate memories but
rather allocate virtual ports on the hardware; i.e. it just flips some
DSP registers. There should be no "memory leaks".
> We can fix it by releasing DSP ports with dsp_free_ports() when
> getting some error.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
> sound/pci/hda/patch_ca0132.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
> index 208933792787..6b8f45e14075 100644
> --- a/sound/pci/hda/patch_ca0132.c
> +++ b/sound/pci/hda/patch_ca0132.c
> @@ -3455,6 +3455,7 @@ static int dspxfr_image(struct hda_codec *codec,
> &port_map_mask);
> if (status < 0) {
> codec_dbg(codec, "alloc ports fail\n");
> + dsp_free_ports(codec);
This is likely superfluous. When an allocation fails, you don't free,
in general.
thanks,
Takashi
next prev parent reply other threads:[~2022-09-07 7:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 6:59 [PATCH] ALSA: hda/ca0132: fix potential memory leak in dspxfr_image() Jianglei Nie
2022-09-07 7:35 ` Takashi Iwai [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-06-29 17:16 Jianglei Nie
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=87illzeixf.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=niejianglei2021@163.com \
--cc=perex@perex.cz \
--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