diff options
| -rw-r--r-- | sound/soc/soc-dapm.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index beb48b608142..a0d97f89eb75 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -308,6 +308,8 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, | |||
| 308 | { | 308 | { |
| 309 | struct dapm_kcontrol_data *data; | 309 | struct dapm_kcontrol_data *data; |
| 310 | struct soc_mixer_control *mc; | 310 | struct soc_mixer_control *mc; |
| 311 | const char *name; | ||
| 312 | int ret; | ||
| 311 | 313 | ||
| 312 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 314 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 313 | if (!data) | 315 | if (!data) |
| @@ -324,6 +326,13 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, | |||
| 324 | if (mc->autodisable) { | 326 | if (mc->autodisable) { |
| 325 | struct snd_soc_dapm_widget template; | 327 | struct snd_soc_dapm_widget template; |
| 326 | 328 | ||
| 329 | name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name, | ||
| 330 | "Autodisable"); | ||
| 331 | if (!name) { | ||
| 332 | ret = -ENOMEM; | ||
| 333 | goto err_data; | ||
| 334 | } | ||
| 335 | |||
| 327 | memset(&template, 0, sizeof(template)); | 336 | memset(&template, 0, sizeof(template)); |
| 328 | template.reg = mc->reg; | 337 | template.reg = mc->reg; |
| 329 | template.mask = (1 << fls(mc->max)) - 1; | 338 | template.mask = (1 << fls(mc->max)) - 1; |
| @@ -334,15 +343,15 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, | |||
| 334 | template.off_val = 0; | 343 | template.off_val = 0; |
| 335 | template.on_val = template.off_val; | 344 | template.on_val = template.off_val; |
| 336 | template.id = snd_soc_dapm_kcontrol; | 345 | template.id = snd_soc_dapm_kcontrol; |
| 337 | template.name = kcontrol->id.name; | 346 | template.name = name; |
| 338 | 347 | ||
| 339 | data->value = template.on_val; | 348 | data->value = template.on_val; |
| 340 | 349 | ||
| 341 | data->widget = snd_soc_dapm_new_control(widget->dapm, | 350 | data->widget = snd_soc_dapm_new_control(widget->dapm, |
| 342 | &template); | 351 | &template); |
| 343 | if (!data->widget) { | 352 | if (!data->widget) { |
| 344 | kfree(data); | 353 | ret = -ENOMEM; |
| 345 | return -ENOMEM; | 354 | goto err_name; |
| 346 | } | 355 | } |
| 347 | } | 356 | } |
| 348 | break; | 357 | break; |
| @@ -353,11 +362,19 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget, | |||
| 353 | kcontrol->private_data = data; | 362 | kcontrol->private_data = data; |
| 354 | 363 | ||
| 355 | return 0; | 364 | return 0; |
| 365 | |||
| 366 | err_name: | ||
| 367 | kfree(name); | ||
| 368 | err_data: | ||
| 369 | kfree(data); | ||
| 370 | return ret; | ||
| 356 | } | 371 | } |
| 357 | 372 | ||
| 358 | static void dapm_kcontrol_free(struct snd_kcontrol *kctl) | 373 | static void dapm_kcontrol_free(struct snd_kcontrol *kctl) |
| 359 | { | 374 | { |
| 360 | struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl); | 375 | struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl); |
| 376 | if (data->widget) | ||
| 377 | kfree(data->widget->name); | ||
| 361 | kfree(data->wlist); | 378 | kfree(data->wlist); |
| 362 | kfree(data); | 379 | kfree(data); |
| 363 | } | 380 | } |
