diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 71fdac067a47bd..49e82131141f0a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2168,11 +2168,21 @@ static int soc_probe(struct platform_device *pdev) static int soc_cleanup_card_resources(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; + struct snd_soc_component *component; + int ret; /* make sure any delayed work runs */ list_for_each_entry(rtd, &card->rtd_list, list) flush_delayed_work(&rtd->delayed_work); + /* remove dynamic controls for all component driver */ + list_for_each_entry(component, &card->component_dev_list, card_list) { + ret = snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); + if (ret < 0) + dev_err(component->dev, + "error: component free failed %d\n", ret); + } + /* free the ALSA card at first; this syncs with pending operations */ snd_card_free(card->snd_card); diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 05d177d689e264..00ab616f1bfc67 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -496,6 +496,7 @@ static void remove_widget(struct snd_soc_component *comp, } free_news: + list_del(&dobj->list); kfree(w->kcontrol_news); /* widget w is freed by soc-dapm.c */