[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87illzeixf.wl-tiwai@suse.de>
Date: Wed, 07 Sep 2022 09:35:08 +0200
From: Takashi Iwai <tiwai@...e.de>
To: Jianglei Nie <niejianglei2021@....com>
Cc: perex@...ex.cz, tiwai@...e.com, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ALSA: hda/ca0132: fix potential memory leak in dspxfr_image()
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@....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
Powered by blists - more mailing lists