From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F931CA9EA0 for ; Mon, 28 Oct 2019 06:30:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7667720659 for ; Mon, 28 Oct 2019 06:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731912AbfJ1GaJ (ORCPT ); Mon, 28 Oct 2019 02:30:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:41178 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730466AbfJ1GaI (ORCPT ); Mon, 28 Oct 2019 02:30:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 372A9B299; Mon, 28 Oct 2019 06:30:07 +0000 (UTC) Date: Mon, 28 Oct 2019 07:30:06 +0100 Message-ID: From: Takashi Iwai To: Navid Emamdoost Cc: emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu, Jaroslav Kysela , Takashi Iwai , Thomas Gleixner , Allison Randal , Tim Blechmann , Hariprasad Kelam , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: lx6464es: Fix memory leaks in snd_lx6464es_create In-Reply-To: <20191027192415.32743-1-navid.emamdoost@gmail.com> References: <20191027192415.32743-1-navid.emamdoost@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 >