From patchwork Wed Nov 8 21:32:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 118344 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5891811qgn; Wed, 8 Nov 2017 15:22:11 -0800 (PST) X-Google-Smtp-Source: ABhQp+Rklg7LmiP5939zO4IVA+R/FD6a2wfI/lNtXTtJpSI9J7qe22M/ayDpFdU8GCsuFWLJoqhe X-Received: by 10.28.135.205 with SMTP id j196mr1610162wmd.144.1510183331012; Wed, 08 Nov 2017 15:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510183331; cv=none; d=google.com; s=arc-20160816; b=BwEAY3ON6xK8MaKJ7RA6MY0VfQ3tYW5czowgoRmz3DhsJcRCdKBJVNAp5Y4yhCZAob wusD6A87T4dlgFEZ8nPTZY3DreLGPxDmSQR3u7cRX1gzX+QsK/oPQYLnDSYGziimSMqt 9f4VIakcvZjBGrxQq3yC6h0ERwiuLQmRXmvCTM9yd8fFr/ix96tfickK9o8nPybTNEJ9 MWmen5ZvcOB0SNpnE8Qo7O62i5t3qN2xFMbvR2q4sQS6ZJntReSo41Q8Nr8gjP6jLhR2 dYddVxV4RegoMrHHmBb59q5fja8JqND3GtciFKaT385bFJMcB3Y/UPP/9vurMjRnDbvr VqIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=WyRQtDjrtxpQ/R95qGV3045GQFwNd1Uylx87FOsREKA=; b=BTJmyKi3qYsCdhUsVFQohgEWd653iP8UjxYjJ1pZt1WnqViG0WM6HN89rMNCnnPDqN MBru+fz9MZsOL1RsvEPvdP9uaoPALsLCPjI+Op5YMKGgfK3Kqs1gtDSnEdvdY3+KMaHw S4ggIczRmrA0Io8heARpHsvvQLDovWr8wZFanb2qSHJkOcZkx4uUQRwvwAtLH9C79VYi bp7GaQ2Rn02KwZWbIWTyc+PkX+i3/TzmTCzLpsPL4CJ8IaOPdi0OHc9GoC4W4Mj+FVSs 3G3IICwLPV1mcHhuvsrCq51Y6SQEIOwz3ffu6yET0o2Bph1v57r/iIk7T1EElDcSiE4V aA+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=smhq9BW7; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id 40si4501873wrz.315.2017.11.08.15.13.46; Wed, 08 Nov 2017 15:22:10 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=smhq9BW7; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 05E80267842; Thu, 9 Nov 2017 00:05:12 +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 7D2E12676B6; Wed, 8 Nov 2017 22:38:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id BCD5F267668 for ; Wed, 8 Nov 2017 22:33:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=zQ7u8TErCDh/eR9sFXqqiqrrQd+rv8w+2lk/Y7tAAJs=; b=smhq9BW7f7IS h1GA9g7lhTZMWGIYP6SIyTTmrXP3jfIfvzdld7cYc6aBMN00wGFPWeXTVn/HZnVkr1eb4sdWRf5GS jITQWH/gLAM7nf2Bj8+1LpDjTjCvTBVTnT7wzdgdHEAKwTsHWdT6GN/udMByEpzm5k2TV5nOxlSi9 O9jJg=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eCXxa-0003gf-CW; Wed, 08 Nov 2017 21:32:34 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1eCXxZ-0005R4-HZ; Wed, 08 Nov 2017 21:32:33 +0000 From: Mark Brown To: Subhransu S. Prusty In-Reply-To: <20171107104626.25800-12-guneshwor.o.singh@intel.com> Message-Id: Date: Wed, 08 Nov 2017 21:32:33 +0000 Cc: alsa-devel@alsa-project.org, Takashi Iwai , Guneshwor Singh , Liam Girdwood , Patches Audio , Mark Brown , Vinod Koul , "Subhransu S. Prusty" Subject: [alsa-devel] Applied "ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure" to the asoc tree 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 The patch ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 1c0a7de226660b0306b54aaf2cb52312e74723eb Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 7 Nov 2017 16:16:26 +0530 Subject: [PATCH] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure During failure, widgets in cvt_list and pin_list are not freed. So fix the possible memory leak by freeing them when failure occurs. Signed-off-by: Subhransu S. Prusty Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 0c0aa6182502..f3b4f4dfae6a 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1453,6 +1453,8 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, int i, num_nodes; struct hdac_device *hdac = &edev->hdac; struct hdac_hdmi_priv *hdmi = edev->private_data; + struct hdac_hdmi_cvt *temp_cvt, *cvt_next; + struct hdac_hdmi_pin *temp_pin, *pin_next; int ret; hdac_hdmi_skl_enable_all_pins(hdac); @@ -1482,32 +1484,54 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, case AC_WID_AUD_OUT: ret = hdac_hdmi_add_cvt(edev, nid); if (ret < 0) - return ret; + goto free_widgets; break; case AC_WID_PIN: ret = hdac_hdmi_add_pin(edev, nid); if (ret < 0) - return ret; + goto free_widgets; break; } } hdac->end_nid = nid; - if (!hdmi->num_pin || !hdmi->num_cvt) - return -EIO; + if (!hdmi->num_pin || !hdmi->num_cvt) { + ret = -EIO; + goto free_widgets; + } ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt); if (ret) { dev_err(&hdac->dev, "Failed to create dais with err: %d\n", ret); - return ret; + goto free_widgets; } *num_dais = hdmi->num_cvt; + ret = hdac_hdmi_init_dai_map(edev); + if (ret < 0) + goto free_widgets; - return hdac_hdmi_init_dai_map(edev); + return ret; + +free_widgets: + list_for_each_entry_safe(temp_cvt, cvt_next, &hdmi->cvt_list, head) { + list_del(&temp_cvt->head); + kfree(temp_cvt->name); + kfree(temp_cvt); + } + + list_for_each_entry_safe(temp_pin, pin_next, &hdmi->pin_list, head) { + for (i = 0; i < temp_pin->num_ports; i++) + temp_pin->ports[i].pin = NULL; + kfree(temp_pin->ports); + list_del(&temp_pin->head); + kfree(temp_pin); + } + + return ret; } static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)