From: Takashi Iwai <tiwai@suse.de>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: Hariprasad Kelam <hariprasad.kelam@gmail.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
kjlu@umn.edu, Takashi Iwai <tiwai@suse.com>,
emamd001@umn.edu, smccaman@umn.edu,
Tim Blechmann <tim@klingt.org>,
Thomas Gleixner <tglx@linutronix.de>,
Allison Randal <allison@lohutok.net>
Subject: Re: [alsa-devel] [PATCH] ALSA: lx6464es: Fix memory leaks in snd_lx6464es_create
Date: Mon, 28 Oct 2019 07:30:06 +0100 [thread overview]
Message-ID: <s5ho8y1mlg1.wl-tiwai@suse.de> (raw)
In-Reply-To: <20191027192415.32743-1-navid.emamdoost@gmail.com>
On Sun, 27 Oct 2019 20:24:13 +0100,
Navid Emamdoost wrote:
>
> In the implementation of snd_lx6464es_create() it there are memory leaks
> when error happens. Go to error path if any of these calls fail:
> lx_init_dsp(), lx_pcm_create(), lx_proc_create(), snd_ctl_add().
Again no for this patch, it'll lead to double-frees.
After registered via snd_device_new(), the device object gets released
by its callback and the single snd_card_free() call suffices.
thanks,
Takashi
>
> Fixes: 02bec4904508 ("ALSA: lx6464es - driver for the digigram lx6464es interface")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> sound/pci/lx6464es/lx6464es.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
> index fe10714380f2..7c6e8f4ef826 100644
> --- a/sound/pci/lx6464es/lx6464es.c
> +++ b/sound/pci/lx6464es/lx6464es.c
> @@ -1020,25 +1020,26 @@ static int snd_lx6464es_create(struct snd_card *card,
> err = lx_init_dsp(chip);
> if (err < 0) {
> dev_err(card->dev, "error during DSP initialization\n");
> - return err;
> + goto cleanup;
> }
>
> err = lx_pcm_create(chip);
> if (err < 0)
> - return err;
> + goto cleanup;
>
> err = lx_proc_create(card, chip);
> if (err < 0)
> - return err;
> + goto cleanup;
>
> err = snd_ctl_add(card, snd_ctl_new1(&lx_control_playback_switch,
> chip));
> if (err < 0)
> - return err;
> + goto cleanup;
>
> *rchip = chip;
> return 0;
>
> +cleanup:
> device_new_failed:
> free_irq(pci->irq, chip);
>
> --
> 2.17.1
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
prev parent reply other threads:[~2019-10-28 6:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-27 19:24 [alsa-devel] [PATCH] ALSA: lx6464es: Fix memory leaks in snd_lx6464es_create Navid Emamdoost
2019-10-27 21:10 ` Markus Elfring
2019-10-28 6:30 ` Takashi Iwai [this message]
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=s5ho8y1mlg1.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=allison@lohutok.net \
--cc=alsa-devel@alsa-project.org \
--cc=emamd001@umn.edu \
--cc=hariprasad.kelam@gmail.com \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=navid.emamdoost@gmail.com \
--cc=smccaman@umn.edu \
--cc=tglx@linutronix.de \
--cc=tim@klingt.org \
--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