From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,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 ADC57C28CC0 for ; Thu, 30 May 2019 04:46:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86A9425BBD for ; Thu, 30 May 2019 04:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559191617; bh=pegDi5gcAt2itKaulnEPA9b3IfsIsZpoclWPbRF2Cks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rNHbJQ6J1Qi8LpA1O6eKycDLh6nblUSoOArlIkJ+ZWarr1/FLuF5BA2+Hqou/f3E4 b94WYflHNNFWxlyeMKXhLW7fktmUMxH/p72RhnDFTbKtnscYI8Kvrb6SOiMB/Y9xz3 6cRb/JKhuUslsUS9XENjcepnzxkaSsoaV6Dn+7iU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728640AbfE3Eqw (ORCPT ); Thu, 30 May 2019 00:46:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:51622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728631AbfE3DLi (ORCPT ); Wed, 29 May 2019 23:11:38 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 7C677244A6; Thu, 30 May 2019 03:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185898; bh=pegDi5gcAt2itKaulnEPA9b3IfsIsZpoclWPbRF2Cks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+gN0+l2O0ea1JByB/dtzjCTkVksnZyrQcSQGiB4/jk+2lQEqAL9PgqhvG+D8XuDE skO6EIwvdcZ9GhTuvZ1A5fqYqhaZxUqTBiYUbR39rWOF8LE8QzFqprUVa4STND9/HR AFpoTLbb/PLLgwU/mE1UIWVE1iflJBUlTVlBtxfM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ranjani Sridharan , Mark Brown , Sasha Levin Subject: [PATCH 5.1 238/405] ASoC: core: remove link components before cleaning up card resources Date: Wed, 29 May 2019 20:03:56 -0700 Message-Id: <20190530030553.048558415@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit f96fb7d198ca624fe33c4145a004eb5a3d0eddec ] When the card is registered by the machine driver, dai link components are probed after the snd_card is created. This is done in snd_soc_bind_card() which calls snd_soc_instantiate_card() to first create the snd_card and then probes the link components by calling soc_probe_link_components(). The snd_card is used by the component driver to add the kcontrols associated with dapm widgets to the card. When the machine driver is unregistered, the snd_card is freed when the card resources are cleaned up. But the snd_card needs to be valid while unloading the topology dapm widgets in order to remove the kcontrols from the card. Since, unloading topology is done when the component driver is removed, the link components should be removed in snd_soc_unbind_card(). This will ensure that the kcontrols are removed before the card resources are cleaned up and the snd_card itself is freed. Signed-off-by: Ranjani Sridharan Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 46e3ab0fced47..fe99b02bbf171 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2828,10 +2828,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card); static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) { + struct snd_soc_pcm_runtime *rtd; + int order; + if (card->instantiated) { card->instantiated = false; snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card); + + /* remove all components used by DAI links on this card */ + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + soc_remove_link_components(card, rtd, order); + } + } + soc_cleanup_card_resources(card); if (!unregister) list_add(&card->list, &unbind_card_list); -- 2.20.1