Commit 18dd66ea authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-core: fixup dead-lock at snd_soc_unregister_component()

snd_soc_unregister_component() is calling snd_soc_lookup_component()
under mutex_lock(). But, snd_soc_lookup_component() itself is using
mutex_lock(), thus it will be dead-lock.
This patch adds _nolocked version of it, and avoid dead-lock issue.

Fixes: ac6a4dd3("ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()")
Reported-by: "kernelci.org bot" <bot@kernelci.org>"
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bltph4da.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent df95a16d
...@@ -356,14 +356,13 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, ...@@ -356,14 +356,13 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
} }
EXPORT_SYMBOL_GPL(snd_soc_rtdcom_lookup); EXPORT_SYMBOL_GPL(snd_soc_rtdcom_lookup);
struct snd_soc_component *snd_soc_lookup_component(struct device *dev, static struct snd_soc_component
const char *driver_name) *snd_soc_lookup_component_nolocked(struct device *dev, const char *driver_name)
{ {
struct snd_soc_component *component; struct snd_soc_component *component;
struct snd_soc_component *found_component; struct snd_soc_component *found_component;
found_component = NULL; found_component = NULL;
mutex_lock(&client_mutex);
for_each_component(component) { for_each_component(component) {
if ((dev == component->dev) && if ((dev == component->dev) &&
(!driver_name || (!driver_name ||
...@@ -373,10 +372,21 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, ...@@ -373,10 +372,21 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
break; break;
} }
} }
mutex_unlock(&client_mutex);
return found_component; return found_component;
} }
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
const char *driver_name)
{
struct snd_soc_component *component;
mutex_lock(&client_mutex);
component = snd_soc_lookup_component_nolocked(dev, driver_name);
mutex_unlock(&client_mutex);
return component;
}
EXPORT_SYMBOL_GPL(snd_soc_lookup_component); EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
...@@ -2855,7 +2865,7 @@ void snd_soc_unregister_component(struct device *dev) ...@@ -2855,7 +2865,7 @@ void snd_soc_unregister_component(struct device *dev)
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
while (1) { while (1) {
component = snd_soc_lookup_component(dev, NULL); component = snd_soc_lookup_component_nolocked(dev, NULL);
if (!component) if (!component)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment