Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3244785imc; Wed, 13 Mar 2019 12:34:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqySfLu4UASMpJyyO0yZCF2+ENmVfYp+jOsznJEj1jPd8JG8SA7PVtl7QHEOmpKrIaV8WIfu X-Received: by 2002:a62:76d4:: with SMTP id r203mr46005950pfc.15.1552505697291; Wed, 13 Mar 2019 12:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552505697; cv=none; d=google.com; s=arc-20160816; b=ilP+9kGCEf/kfm+HVIaXzw9kBRHBV7Ol+gzEahjY1QpUfAYYLOpAbXCm8kfO6BjeZo bAPpv87HzJNDgzSDNMORMs2CMD9A5ryoI/dX00xxxq11LJn6S0LEUiAVhQUJ8PqD1CTP fXE+q4H7EPtdthjnXHsRd7L2hyXjUboCIM4hyZURmKVW1wtEbSrUjIKhXOZlRPsPxJMS DyVwPGC0IOuP2iHNDUo/Ni4x/ickzGG7Fk+SUgBMqoipjmiMAd8XoQW8Q32+cCjHT7yb R3k4hygPLBUcZed8I4yyVKpV8m3Kwqp9Hi8u0P66Ubm2p03uDE3fjoHP54NpLsif8zgH 76Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cTTjlT/4K4bc4HB5cjRz+zxYY5ZMC50WKoYCsVrgf0c=; b=TDVSyrnVNXBL4eIb5WAd+HloewZWdam++lpjfsIGwMsoufEBf6F8oFAFBaHi3tmtPv S84iRGHEsH+884ANlkWLT+3vv1TRmjStk8GUQahTsZ8u+h/lAnImisEuLBqmzxZvMaac 0FAFRnlC7JvUvC7Ayi/GWplCEh19zCUu0EZAfdQQ4RvY6qOC5Dr5TuDfINzMSp2ABFQk D6ZbretemRJ1LO+FifpwQ+kmQbquZrbsEQJjQ+QtR57fovAI2RC6SbmEadX3Nq+UKq6h neIs+dJH5cSqLAnxdijXctcxyfsqPps7WVbteSPENp9ZmYiUBd2IHVTk59SgU3PExu7D XPvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i44fms35; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si10826272pga.284.2019.03.13.12.34.41; Wed, 13 Mar 2019 12:34:57 -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=@kernel.org header.s=default header.b=i44fms35; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727373AbfCMTLM (ORCPT + 99 others); Wed, 13 Mar 2019 15:11:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:41724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727352AbfCMTLK (ORCPT ); Wed, 13 Mar 2019 15:11:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7AF032177E; Wed, 13 Mar 2019 19:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552504269; bh=fevIuAiKjrqsifqHv9nuVlqfBUelnUXxxO5PPa5RYFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i44fms35Iq8eT+uCg9tx8DjZrmAzpWZWhfaZWf8TB/4oLpeJb3Pe73GJRuDGEsDC4 7DnJ3qQdBaAFplx8g4xUhzm3/QWsGURj67wB1PjHnYdbIbTU71007S27cR/99Fyv86 BOta/RRc6wlyarKQpk8Oy3qFWYk8x/+BI5WLcHM0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bard liao , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.20 23/60] ASoC: topology: free created components in tplg load error Date: Wed, 13 Mar 2019 15:09:44 -0400 Message-Id: <20190313191021.158171-23-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190313191021.158171-1-sashal@kernel.org> References: <20190313191021.158171-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bard liao [ Upstream commit 304017d31df36fb61eb2ed3ebf65fb6870b3c731 ] Topology resources are no longer needed if any element failed to load. Signed-off-by: Bard liao Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-topology.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 045ef136903d..82b3274e408b 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -2482,6 +2482,7 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp, struct snd_soc_tplg_ops *ops, const struct firmware *fw, u32 id) { struct soc_tplg tplg; + int ret; /* setup parsing context */ memset(&tplg, 0, sizeof(tplg)); @@ -2495,7 +2496,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp, tplg.bytes_ext_ops = ops->bytes_ext_ops; tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count; - return soc_tplg_load(&tplg); + ret = soc_tplg_load(&tplg); + /* free the created components if fail to load topology */ + if (ret) + snd_soc_tplg_component_remove(comp, SND_SOC_TPLG_INDEX_ALL); + + return ret; } EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load); -- 2.19.1