Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH] ASoC: core: Fix component_list corruption when unloading modules
Date: Mon, 28 Apr 2014 15:26:59 +0200	[thread overview]
Message-ID: <535E5723.4070200@metafoo.de> (raw)
In-Reply-To: <1398688251-11374-1-git-send-email-jarkko.nikula@linux.intel.com>

On 04/28/2014 02:30 PM, Jarkko Nikula wrote:
> 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>

Thanks.

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
>   sound/soc/soc-core.c | 25 +++++++++++++++----------
>   1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index f18112a32541..62c3980fad5b 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -4061,6 +4061,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
>    *
> @@ -4076,14 +4088,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);
>
> @@ -4183,7 +4188,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);
> @@ -4388,7 +4393,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);
>

  reply	other threads:[~2014-04-28 13:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 12:30 [PATCH] ASoC: core: Fix component_list corruption when unloading modules Jarkko Nikula
2014-04-28 13:26 ` Lars-Peter Clausen [this message]
2014-04-29 17:09 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=535E5723.4070200@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox