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 8A5EDCA9EA0 for ; Mon, 28 Oct 2019 06:32:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F2C120862 for ; Mon, 28 Oct 2019 06:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731948AbfJ1Gc4 (ORCPT ); Mon, 28 Oct 2019 02:32:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:41906 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729298AbfJ1Gc4 (ORCPT ); Mon, 28 Oct 2019 02:32:56 -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 7DE1AB3C7; Mon, 28 Oct 2019 06:32:54 +0000 (UTC) Date: Mon, 28 Oct 2019 07:32:54 +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 , Richard Fontana , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: pci: Fix memory leak in snd_ali_create In-Reply-To: <20191027183030.12677-1-navid.emamdoost@gmail.com> References: <20191027183030.12677-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 19:30:27 +0100, Navid Emamdoost wrote: > > In the implementation of snd_ali_create() the memory allocated for codec > is leaked in case of an error. Release codec if snd_ali_chip_init() > fails. Once again, this is a wrong fix. The code path is after snd_device_new() with the free op, so the object gets already released there. thanks, Takashi > > Fixes: f9ab2b1c3ab5 ("[ALSA] ali5451 - Code clean up, irq handler fix") > Signed-off-by: Navid Emamdoost > --- > sound/pci/ali5451/ali5451.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c > index 6e28e381c21a..3ed07a18be4d 100644 > --- a/sound/pci/ali5451/ali5451.c > +++ b/sound/pci/ali5451/ali5451.c > @@ -2179,6 +2179,7 @@ static int snd_ali_create(struct snd_card *card, > err = snd_ali_chip_init(codec); > if (err < 0) { > dev_err(card->dev, "ali create: chip init error.\n"); > + snd_ali_free(codec); > return err; > } > > -- > 2.17.1 >