Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4096283pxa; Sun, 9 Aug 2020 23:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycl7ymglxy6Pa7P18jBjF8VdoMEy1Irn9IOmNAk1hmZVJpNLQ+SKvqsFQxCO7p+P3W3NmH X-Received: by 2002:a1c:e244:: with SMTP id z65mr23710502wmg.34.1597042764565; Sun, 09 Aug 2020 23:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597042764; cv=none; d=google.com; s=arc-20160816; b=WZW9pquCrkj105FrzvSaq1WaBbUUQTC+kpBREb9PXs1mnlsYPnQ2onOtr333As0KMP AhbV2Wa3Yvk9OQStjb8xsgsWFj/sFUMyKSEatGBwnZuGw2lO/nGL1djlS6Zhf5RNsf/g Xob+j6YeQ2JFRz7GgmftX3ofsYV9nrY0fT4oaqaj3fWkmAXcjGKNE4jXrzpowCkTf/Hi ta+tsE45PDi65OK2UknrGq6l77ogkCvkYZtJm5wTlxEbJd4G+PMlZhLNt29KtU3rOu85 gy4Sph1nZrNdmKzLHBPqbdv0LkjcAw8QrQyRxcfNCwwzhVi1sOaip0E1iNMLcXI4vQSn GN9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=xtU/wp+aIhXzmfODJREAGRDF88FdX+Uta+qKgtBxz4Y=; b=jNfbkjyn8YZ0L77eCKr6+ck6Nn1fyCFD1VdPWjYQ680ES6WhwIjvNsibvnzaeFYnAt U0TQ7R2CPr+y5Wt4YCSBJUWIYPOhxxNCRCIn7JBUYBetRM46UrRSzn3wovPdmqkhw/UY aZQmIQRhd/yhBLli+wttwcEso5dYSIDVntPl5aXpr5ceYddKWC4eBU/Qr4/SaYDS/Lbn MWobYm2No6ZGr4K5G8dEi3/RpUmEp2OmKQ3Qi8Uhfezevhy6r42jUUw6M0RUfIyweZh/ YKjDVFsQjwBGy4Kj94v2BZoU/7hd8d8sBeBF24p8Z0dEz5ZaKsuyZUSgHIOx2Nq8TXcJ wQsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si10406029ejf.352.2020.08.09.23.59.01; Sun, 09 Aug 2020 23:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725849AbgHJG6L (ORCPT + 99 others); Mon, 10 Aug 2020 02:58:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:48788 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgHJG6L (ORCPT ); Mon, 10 Aug 2020 02:58:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 20914ACA7; Mon, 10 Aug 2020 06:58:30 +0000 (UTC) Date: Mon, 10 Aug 2020 08:58:09 +0200 Message-ID: From: Takashi Iwai To: Dinghao Liu Cc: kjlu@umn.edu, Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , Eliot Blennerhassett , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: pci/asihpi: Fix memory leak in snd_card_asihpi_capture_open() In-Reply-To: <20200810063957.13692-1-dinghao.liu@zju.edu.cn> References: <20200810063957.13692-1-dinghao.liu@zju.edu.cn> 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 Mon, 10 Aug 2020 08:39:55 +0200, Dinghao Liu wrote: > > When snd_pcm_hw_constraint_pow2() fails, dpcm should be freed > just like when hpi_instream_open() fails. It will be cleaned up via runtime->private_free call in the caller side (snd_pcm_open -> snd_pcm_release_substream -> snd_pcm_detach_substream), hence this would result in double-free. thanks, Takashi > > Fixes: 719f82d3987aa ("ALSA: Add support of AudioScience ASI boards") > Signed-off-by: Dinghao Liu > --- > sound/pci/asihpi/asihpi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c > index 023c35a2a951..736eceacd3d0 100644 > --- a/sound/pci/asihpi/asihpi.c > +++ b/sound/pci/asihpi/asihpi.c > @@ -1244,8 +1244,10 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) > if (card->can_dma) > err = snd_pcm_hw_constraint_pow2(runtime, 0, > SNDRV_PCM_HW_PARAM_BUFFER_BYTES); > - if (err < 0) > + if (err < 0) { > + kfree(dpcm); > return err; > + } > > snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, > card->update_interval_frames); > -- > 2.17.1 >