From patchwork Tue Mar 10 12:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 229505 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=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 08B90C18E5A for ; Tue, 10 Mar 2020 13:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3AC120675 for ; Tue, 10 Mar 2020 13:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583846931; bh=7Scp6//mAPz4NYiDJP3JAf5lYqrOlQC1f0iLzt9VoyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2jJJ/BizY9lMv5sXcB0S+GE32hyUnr9pMbmJtTrI7uI3WPTj0wQqTtlDRCvLqKEm+ CSRWIlXdtqdiAqPsq1pCB/YGDc6PwXjB1FNXcwKKZh0IjFoEYov34GA645NmyAgiCe 9iCxNTabooiX8r72v/26mxC0IDgWFJEsJWEdwnYw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbgCJN2s (ORCPT ); Tue, 10 Mar 2020 09:28:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:58922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgCJMxE (ORCPT ); Tue, 10 Mar 2020 08:53:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 62A7A24694; Tue, 10 Mar 2020 12:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844783; bh=7Scp6//mAPz4NYiDJP3JAf5lYqrOlQC1f0iLzt9VoyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hvCSCnYwVXyZCABzjgoaK0az6jUYtGWnTXnNOUuQP3H3sUZSwad17SJi7dAe0L1S1 FcDYLHNdZi2LQiOJ1CO1HXuwwLmEGUfZxuCitVp3hq0JZI2vMtP+A12IAs9nGiYJJP N+BRgJx7XlepTzUX3g8K15g4hRR36SQGxLiyBewo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dragos Tarcatu , Mark Brown Subject: [PATCH 5.4 118/168] ASoC: topology: Fix memleak in soc_tplg_manifest_load() Date: Tue, 10 Mar 2020 13:39:24 +0100 Message-Id: <20200310123647.342564579@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123635.322799692@linuxfoundation.org> References: <20200310123635.322799692@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dragos Tarcatu commit 242c46c023610dbc0213fc8fb6b71eb836bc5d95 upstream. In case of ABI version mismatch, _manifest needs to be freed as it is just a copy of the original topology manifest. However, if a driver manifest handler is defined, that would get executed and the cleanup is never reached. Fix that by getting the return status of manifest() instead of returning directly. Fixes: 583958fa2e52 ("ASoC: topology: Make manifest backward compatible from ABI v4") Signed-off-by: Dragos Tarcatu Link: https://lore.kernel.org/r/20200207185325.22320-3-dragos_tarcatu@mentor.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-topology.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -2488,7 +2488,7 @@ static int soc_tplg_manifest_load(struct { struct snd_soc_tplg_manifest *manifest, *_manifest; bool abi_match; - int err; + int ret = 0; if (tplg->pass != SOC_TPLG_PASS_MANIFEST) return 0; @@ -2501,19 +2501,19 @@ static int soc_tplg_manifest_load(struct _manifest = manifest; } else { abi_match = false; - err = manifest_new_ver(tplg, manifest, &_manifest); - if (err < 0) - return err; + ret = manifest_new_ver(tplg, manifest, &_manifest); + if (ret < 0) + return ret; } /* pass control to component driver for optional further init */ if (tplg->comp && tplg->ops && tplg->ops->manifest) - return tplg->ops->manifest(tplg->comp, tplg->index, _manifest); + ret = tplg->ops->manifest(tplg->comp, tplg->index, _manifest); if (!abi_match) /* free the duplicated one */ kfree(_manifest); - return 0; + return ret; } /* validate header magic, size and type */