[alsa-devel] [PATCH] ASoC: soc-core: Add support for NULL default register caches

Liam Girdwood lrg at slimlogic.co.uk
Mon Jan 10 22:48:58 CET 2011


On Mon, 2011-01-10 at 10:10 +0000, Dimitris Papastamos wrote:
> The infrastructure for handling NULL default register maps is already
> included in the soc-cache code, just ensure that we don't try to dereference
> a NULL pointer while accessing a NULL register cache.
> 
> Signed-off-by: Dimitris Papastamos <dp at opensource.wolfsonmicro.com>
> ---
>  sound/soc/soc-core.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index bac7291..a9f19c1 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -3503,11 +3503,13 @@ int snd_soc_register_codec(struct device *dev,
>  		 * kernel might have freed the array by the time we initialize
>  		 * the cache.
>  		 */
> -		codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
> -					      reg_size, GFP_KERNEL);
> -		if (!codec->reg_def_copy) {
> -			ret = -ENOMEM;
> -			goto fail;
> +		if (codec_drv->reg_cache_default) {
> +			codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
> +						      reg_size, GFP_KERNEL);
> +			if (!codec->reg_def_copy) {
> +				ret = -ENOMEM;
> +				goto fail;
> +			}
>  		}
>  	}
>  

Acked-by: Liam Girdwood <lrg at slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk



More information about the Alsa-devel mailing list