From fb19d1d89525511d6fcd94388724eaabd29fe7c5 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 12 Nov 2019 14:07:02 -0600 Subject: [PATCH] ASoC: soc-core: fix kernel oops on dai link remove soc_dai_link_remove() can be called from topology or on cleanup the card. The kernel oopses if soc_unbind_dai_link() is called in the first case, so add a boolean parameter and conditionally call soc_unbind_dai_link() Fixes: bc7a9091e5b92 ("ASoC: soc-core: add soc_unbind_dai_link()") Signed-off-by: Pierre-Louis Bossart --- include/sound/soc.h | 3 ++- sound/soc/soc-core.c | 9 ++++++--- sound/soc/soc-topology.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index e0855dc08d30eb..c599a9f12dda33 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1328,7 +1328,8 @@ void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); int snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link); + struct snd_soc_dai_link *dai_link, + bool unbind); struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, int id, const char *name, const char *stream_name); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 55014e7ae0d823..762778a7da77bd 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1469,6 +1469,7 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); * snd_soc_remove_dai_link - Remove a DAI link from the list * @card: The ASoC card that owns the link * @dai_link: The DAI link to remove + * @unbind: unbind dai link * * This function removes a DAI link from the ASoC card's link list. * @@ -1476,7 +1477,8 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); * remove them by using the dobj embedded in the link. */ void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) + struct snd_soc_dai_link *dai_link, + bool unbind) { lockdep_assert_held(&client_mutex); @@ -1488,7 +1490,8 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, list_del(&dai_link->list); - soc_unbind_dai_link(card, dai_link); + if (unbind) + soc_unbind_dai_link(card, dai_link); } EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); @@ -1997,7 +2000,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card) soc_remove_link_dais(card); for_each_card_links_safe(card, link, _link) - snd_soc_remove_dai_link(card, link); + snd_soc_remove_dai_link(card, link, true); /* remove auxiliary devices */ soc_remove_aux_devices(card); diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 81d2af000a5c80..8072f8f5db1787 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -553,7 +553,7 @@ static void remove_link(struct snd_soc_component *comp, kfree(link->cpus->dai_name); list_del(&dobj->list); - snd_soc_remove_dai_link(comp->card, link); + snd_soc_remove_dai_link(comp->card, link, false); kfree(link); }