[alsa-devel] [PATCH v2 3/5] ASoC: dapm: Append "Autodisable" to autodisable widget names

Lars-Peter Clausen lars at metafoo.de
Thu Apr 30 19:40:42 CEST 2015


On 04/30/2015 06:38 PM, Charles Keepax wrote:
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index beb48b6..e557018 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -308,11 +308,19 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
>   {
>   	struct dapm_kcontrol_data *data;
>   	struct soc_mixer_control *mc;
> +	const char *name;
> +	int ret;
>
>   	data = kzalloc(sizeof(*data), GFP_KERNEL);
>   	if (!data)
>   		return -ENOMEM;
>
> +	name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name, "Autodisable");

We should only allocate the name if we create a widget, otherwise we are 
going to leak the memory.

> +	if (!name) {
> +		ret = -ENOMEM;
> +		goto err_data;
> +	}
> +
>   	INIT_LIST_HEAD(&data->paths);
>



More information about the Alsa-devel mailing list