Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131672ybi; Mon, 29 Jul 2019 01:26:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRWFDyy5n7LsAFafQvFDtvQaTyI8k87VoFQ5L6H+SyNL4pSTWVLQhYeCgIpwjw757aa6pu X-Received: by 2002:a17:90a:db42:: with SMTP id u2mr111135096pjx.48.1564388764010; Mon, 29 Jul 2019 01:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564388764; cv=none; d=google.com; s=arc-20160816; b=LgBOU4fhocgnipbrXj/HUA3GJwU+E+1m7JRvQS+NeG2ypsbfEv7fVQf22/+cz4aBP3 ikwLTmtaXtISXL99oJI9JkrzDnmD1bvhleEPLounIg03KiwjSVXfD97LY3w3KuY2lOL9 dVb5b2yRTTT038R7UCWOPfFpr9jd0+zStnBnakraF211sZ8G7KlsHWu7C9/hMFQ5laBD OyrCSAclO8WN0op9Ek2//lmIUpMJ14Z/QRStJwiqH8jzF3WZtaudN79IpM6Mux9raV+7 mID6GHSBDpDaKTLlrazaATJPcq8glUcyepUflVap/EdbcvF5Z8oIqXz8oNTcjnSE5NKF uE6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WRFRbbdfaf0Y2ROtu21La93Edhg0Qj+U7zL+OJ4cOJo=; b=jq+deU7SyL5EmB5EVw9ZR89YO4wV3tYDY/azddklOxDsf0uWO60hWzxpR/XILeog8x puvOZI14Ui99zEKlgILZhzPkECkVGm75YtSWxPCxHGTz3/9VztTtYuwlQec7P9e660Ux zuAon1KPHQtBOcLIlsZjcILpi5+/DY0kOhioIG08Vu81kZiUj1/C0vDCXiBFoDbf/Dz3 Ns5MVnmGzCTVVppK8AvAxLaz7emPt3l1ny1FkUJ58COqP+o3JuchIAXMW4vyojI2ZdxO S3qrwdNVes8paSReNxLrcMSVLcicTR3tRUJupD4+QcxeFKceL9z3k5pBOXNMzFvlnjl+ 7Amg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b="UExwS/mu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y187si29586490pgb.480.2019.07.29.01.25.48; Mon, 29 Jul 2019 01:26:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b="UExwS/mu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbfG2ITb (ORCPT + 99 others); Mon, 29 Jul 2019 04:19:31 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:42774 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfG2ITa (ORCPT ); Mon, 29 Jul 2019 04:19:30 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x6T8EAvi014828; Mon, 29 Jul 2019 03:18:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=WRFRbbdfaf0Y2ROtu21La93Edhg0Qj+U7zL+OJ4cOJo=; b=UExwS/mu1oC8AJJIO+I3MLnokg1b4ditpCvaNSLlHge7MQ5JZLyRa22nZ19JYdzqKZwn j7TgIew0AuMbfCF3yWZAJoFE86kpOdPQaoM1rQ1BZAfKce4Ulaq8m2jbMmzcQb1Tg1/f xQdS9+lyOrBZbDBubz0KMVXDBiESrbEHjvySeiYOBnrGMPEJI/312L+Q/0PESJQshGuW 04tEWJo3db01NMlfHiX0hjE8mBoopot479VdCgWt9nWtHhXYT2E2f7gIj14lISnDDsa5 UB1OPcRXbaaPrcEL7hRXaPUW6CMMxJtqp/IV0vU3vE8OVur5s2OWOpCIZWIDsQa76jlK qA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 2u0k1qthc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 29 Jul 2019 03:18:37 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Mon, 29 Jul 2019 09:18:35 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Mon, 29 Jul 2019 09:18:35 +0100 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AB50F2A1; Mon, 29 Jul 2019 09:18:35 +0100 (BST) Date: Mon, 29 Jul 2019 09:18:35 +0100 From: Charles Keepax To: Satendra Singh Thakur CC: , Liam Girdwood , , Takashi Iwai , Mark Brown Subject: Re: [alsa-devel] [PATCH] [ASoC][soc-dapm] : memory leak in the func snd_soc_dapm_new_dai Message-ID: <20190729081835.GE54126@ediswmail.ad.cirrus.com> References: <20190725161335.4162-1-thakursatendra2003@yahoo.co.in> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190725161335.4162-1-thakursatendra2003@yahoo.co.in> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=2 mlxlogscore=830 lowpriorityscore=0 priorityscore=1501 impostorscore=0 clxscore=1011 phishscore=0 adultscore=0 mlxscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1907290098 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 09:43:35PM +0530, Satendra Singh Thakur wrote: > In the func snd_soc_dapm_new_dai, if the inner func > snd_soc_dapm_alloc_kcontrol fails, there will be memory leak. > The label param_fail wont free memory which is allocated by > the func devm_kcalloc. Hence new label is created for this purpose. > > Signed-off-by: Satendra Singh Thakur > --- > sound/soc/soc-dapm.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c > index f013b24c050a..f62d41ee6d68 100644 > --- a/sound/soc/soc-dapm.c > +++ b/sound/soc/soc-dapm.c > @@ -4095,7 +4095,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, > w_param_text, &private_value); > if (!template.kcontrol_news) { > ret = -ENOMEM; > - goto param_fail; > + goto outfree_w_param; > } > } else { > w_param_text = NULL; > @@ -4114,6 +4114,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, > > outfree_kcontrol_news: > devm_kfree(card->dev, (void *)template.kcontrol_news); > +outfree_w_param: > snd_soc_dapm_free_kcontrol(card, &private_value, > rtd->dai_link->num_params, w_param_text); This is not necessary snd_soc_dapm_alloc_kcontrol calls snd_soc_dapm_free_kcontrol on its internal error path. Thanks, Charles