summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorJarkko Nikula2014-04-28 14:30:51 +0200
committerMark Brown2014-04-29 19:09:11 +0200
commit4da533932dedff930596bc536adaba1e508f9ffa (patch)
treeb3e54c8d576cf3c0a05652a0d184c286908389de /sound/soc/soc-core.c
parentASoC: Move standard kcontrol helpers to the component level (diff)
downloadkernel-qcow2-linux-4da533932dedff930596bc536adaba1e508f9ffa.tar.gz
kernel-qcow2-linux-4da533932dedff930596bc536adaba1e508f9ffa.tar.xz
kernel-qcow2-linux-4da533932dedff930596bc536adaba1e508f9ffa.zip
ASoC: core: Fix component_list corruption when unloading modules
This fixes module unload regressions introduced by commits 98e639fb8a3e ("ASoC: Track which components have been registered with snd_soc_register_component()") and b37f1d123c69 ("ASoC: Let snd_soc_platform subclass snd_soc_component"). First commit causes component_list to be corrupted when removing codec and second when removing platform. Reason for both is that components associated with platform or codec are never removed from the list because for them registered_as_component field in struct snd_soc_component is always false. Now list becomes corrupted when snd_soc_unregister_platform() or snd_soc_unregister_codec() frees the platform or codec structure and where the associated struct snd_soc_component is embedded. Fix these by moving component unregistration and cleanup to a new local function __snd_soc_unregister_component() that takes component as its argument. Since component is known for platforms and codecs the __snd_soc_unregister_component() can be called directly and snd_soc_unregister_component() takes care to find and unregister only components that were registered using snd_soc_register_component(). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d5cd80b6d320..4a381b307b08 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4010,6 +4010,18 @@ int snd_soc_register_component(struct device *dev,
}
EXPORT_SYMBOL_GPL(snd_soc_register_component);
+static void __snd_soc_unregister_component(struct snd_soc_component *cmpnt)
+{
+ snd_soc_unregister_dais(cmpnt);
+
+ mutex_lock(&client_mutex);
+ list_del(&cmpnt->list);
+ mutex_unlock(&client_mutex);
+
+ dev_dbg(cmpnt->dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
+ kfree(cmpnt->name);
+}
+
/**
* snd_soc_unregister_component - Unregister a component from the ASoC core
*
@@ -4025,14 +4037,7 @@ void snd_soc_unregister_component(struct device *dev)
return;
found:
- snd_soc_unregister_dais(cmpnt);
-
- mutex_lock(&client_mutex);
- list_del(&cmpnt->list);
- mutex_unlock(&client_mutex);
-
- dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
- kfree(cmpnt->name);
+ __snd_soc_unregister_component(cmpnt);
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
@@ -4132,7 +4137,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform);
*/
void snd_soc_remove_platform(struct snd_soc_platform *platform)
{
- snd_soc_unregister_component(platform->dev);
+ __snd_soc_unregister_component(&platform->component);
mutex_lock(&client_mutex);
list_del(&platform->list);
@@ -4337,7 +4342,7 @@ void snd_soc_unregister_codec(struct device *dev)
return;
found:
- snd_soc_unregister_component(dev);
+ __snd_soc_unregister_component(&codec->component);
mutex_lock(&client_mutex);
list_del(&codec->list);