[<prev] [next>] [day] [month] [year] [list]
Message-ID: <87bltph4da.wl-kuninori.morimoto.gx@renesas.com>
Date: Wed, 06 Nov 2019 16:05:05 +0900
From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To: Mark Brown <broonie@...nel.org>
Cc: "kernelci.org bot" <bot@...nelci.org>, tomeu.vizoso@...labora.com,
guillaume.tucker@...labora.com, mgalka@...labora.com,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>,
matthew.hart@...aro.org, khilman@...libre.com,
enric.balletbo@...labora.com, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
Liam Girdwood <lgirdwood@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] ASoC: soc-core: fixup dead-lock at snd_soc_unregister_component()
From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
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: ac6a4dd3e9f0("ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()")
Reported-by: "kernelci.org bot" <bot@...nelci.org>"
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
---
> Please double check/test it.
sound/soc/soc-core.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cc59687..94f1078 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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);
-struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
- const char *driver_name)
+static struct snd_soc_component
+*snd_soc_lookup_component_nolocked(struct device *dev, const char *driver_name)
{
struct snd_soc_component *component;
struct snd_soc_component *found_component;
found_component = NULL;
- mutex_lock(&client_mutex);
for_each_component(component) {
if ((dev == component->dev) &&
(!driver_name ||
@@ -373,10 +372,21 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
break;
}
}
- mutex_unlock(&client_mutex);
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);
struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
@@ -2853,7 +2863,7 @@ void snd_soc_unregister_component(struct device *dev)
mutex_lock(&client_mutex);
while (1) {
- component = snd_soc_lookup_component(dev, NULL);
+ component = snd_soc_lookup_component_nolocked(dev, NULL);
if (!component)
break;
--
2.7.4
Powered by blists - more mailing lists