From: Takashi Iwai <tiwai@suse.de>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu
Subject: Re: [PATCH] ALSA: trident: Fix a memory leak in snd_trident_create
Date: Sat, 11 Jul 2020 11:04:12 +0200 [thread overview]
Message-ID: <s5htuye2zjn.wl-tiwai@suse.de> (raw)
In-Reply-To: <20200711070835.4855-1-navid.emamdoost@gmail.com>
On Sat, 11 Jul 2020 09:08:30 +0200,
Navid Emamdoost wrote:
>
> In the implementation of snd_trident_create(), the allocated trident is
> leaked if snd_trident_mixer() fails. Release via snd_trident_free().
No, this patch would result in double-free.
The manual release of trident object isn't needed once after it gets
added via snd_device_new(). Then it'll be automatically released at
the error path (via snd_trident_dev_free()).
thanks,
Takashi
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> sound/pci/trident/trident_main.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
> index 6e50376163a2..e98c692f6aa9 100644
> --- a/sound/pci/trident/trident_main.c
> +++ b/sound/pci/trident/trident_main.c
> @@ -3582,8 +3582,11 @@ int snd_trident_create(struct snd_card *card,
> return err;
> }
>
> - if ((err = snd_trident_mixer(trident, pcm_spdif_device)) < 0)
> + err = snd_trident_mixer(trident, pcm_spdif_device);
> + if (err < 0) {
> + snd_trident_free(trident);
> return err;
> + }
>
> /* initialise synth voices */
> for (i = 0; i < 64; i++) {
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-07-11 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-11 7:08 Navid Emamdoost
2020-07-11 9:04 ` Takashi Iwai [this message]
2020-07-11 18:16 ` Navid Emamdoost
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=s5htuye2zjn.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=navid.emamdoost@gmail.com \
--cc=perex@perex.cz \
--cc=smccaman@umn.edu \
--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®