From patchwork Mon Feb 22 08:44:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8373351 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 242DEC0553 for ; Mon, 22 Feb 2016 08:45:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53E45203AA for ; Mon, 22 Feb 2016 08:45:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1E6D52039E for ; Mon, 22 Feb 2016 08:45:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 552622659EF; Mon, 22 Feb 2016 09:45:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 62E762655B6; Mon, 22 Feb 2016 09:45:03 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7EE972655B6; Mon, 22 Feb 2016 09:45:02 +0100 (CET) Received: from mail-pf0-f172.google.com (mail-pf0-f172.google.com [209.85.192.172]) by alsa0.perex.cz (Postfix) with ESMTP id F17772659E7 for ; Mon, 22 Feb 2016 09:44:47 +0100 (CET) Received: by mail-pf0-f172.google.com with SMTP id q63so89214668pfb.0 for ; Mon, 22 Feb 2016 00:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=sARAS67Z+OkB9TKSDUlWf8Hk1EyTxspCe4FRtn9gTt8=; b=GEl2ZDtLtzEWYDvExL5NeZbcq2Xwqe6RtfwDLnV8DbGd+PISBmIdXu3RGDZ/T2j++X 8Ad7+kMGZdDON/IlgH7nuAnH00l3IHblEEfP513n1v+b9c9Hozn/pxLjXJEZqNBsG+u9 VgHoujvuIds1FMBu7rMhYxszpaqMq2ahQsDU7TXNO1OLjNgSRlsB1ksbqS8I4ps/FRwe pHnv86Cd0oRlz7wbM2J3Xq8o+VY6IBS7H7W6+iQBjVFm2rzWq2B0B7DxrPnP7WFWphkY YbCzFoSbcUJuzWArM1SuqanDsn+apvWhAlX8oZ9GJJsv52RvOiROYmODbCqrDYd6AFeB 4RjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sARAS67Z+OkB9TKSDUlWf8Hk1EyTxspCe4FRtn9gTt8=; b=bjhueEU3njmF9yIR4isn/qAqWrkNtdNgPNQYT7by5+Ybe077YsD8ydhpzr52TveL/6 avyc8Twd2IYbhISroY5zi5BxOftmQcahQSjsC/5EMZNWmI6WPJ9TOa2z7bxuBuMzs+XZ YoBb1ERg/vboOxrdnOFJmnWVCEfDtO28PvU1UsRkdUHkYiVh5d8/OULuFw1nqN/wOWLc eF3k7tz3IWgEZD0BlSi2CPczsDRTEItvE9cx3ELFWZCgJyoHbKFEd1qN9mAdjHV4XohM NoKcelPlEuz17N20Ao3Z9P7QaBSd3wdazabvbE2luZhXObbstuaxowIaKN+8eT8GmJoX XT8A== X-Gm-Message-State: AG10YOS0dxbB8eCMDKCzD2BxI78I1jwj/vFz191vHwYhDYJ5683K03C/1FORvyBFLgWAVQ== X-Received: by 10.98.69.1 with SMTP id s1mr35954671pfa.120.1456130686793; Mon, 22 Feb 2016 00:44:46 -0800 (PST) Received: from sudip-pc.vectortproxy.org ([14.195.238.223]) by smtp.gmail.com with ESMTPSA id r87sm34890524pfa.61.2016.02.22.00.44.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 00:44:45 -0800 (PST) From: Sudip Mukherjee To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Date: Mon, 22 Feb 2016 14:14:31 +0530 Message-Id: <1456130671-12365-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [alsa-devel] [PATCH] ASoC: fix memory leak X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP If dai_link is already bound then we just returned and leaked rtd and rtd->codec_dais which were allocated by soc_new_pcm_runtime(). We do not need this newly allocated rtd to check if dai_link is already binded. Lets check first if it is already binded before allocating this memory. Signed-off-by: Sudip Mukherjee --- sound/soc/soc-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 790ee2b..d2e62b15 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -986,16 +986,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card, dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name); - rtd = soc_new_pcm_runtime(card, dai_link); - if (!rtd) - return -ENOMEM; - if (soc_is_dai_link_bound(card, dai_link)) { dev_dbg(card->dev, "ASoC: dai link %s already bound\n", dai_link->name); return 0; } + rtd = soc_new_pcm_runtime(card, dai_link); + if (!rtd) + return -ENOMEM; + cpu_dai_component.name = dai_link->cpu_name; cpu_dai_component.of_node = dai_link->cpu_of_node; cpu_dai_component.dai_name = dai_link->cpu_dai_name;