Skip to content

Commit

Permalink
ASoC: Fix memory allocation for snd_soc_dapm_switch names
Browse files Browse the repository at this point in the history
snd_soc_dapm_switch ends up ends up in dapm_new_mixer() (since a switch
is a special case of a mixer with only one input) but this wasn't
correctly handled in the code.

Also fix the coding style for the switch below while we're here.

Reported-by: Joonyoung Shim <dofmind@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Mar 6, 2009
1 parent b0c5033 commit 07495f3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
* kcontrol name.
*/
name_len = strlen(w->kcontrols[i].name) + 1;
if (w->id == snd_soc_dapm_mixer)
if (w->id != snd_soc_dapm_mixer_named_ctl)
name_len += 1 + strlen(w->name);

path->long_name = kmalloc(name_len, GFP_KERNEL);
Expand All @@ -341,15 +341,14 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
return -ENOMEM;

switch (w->id) {
case snd_soc_dapm_mixer:
default:
snprintf(path->long_name, name_len, "%s %s",
w->name, w->kcontrols[i].name);
break;
break;
case snd_soc_dapm_mixer_named_ctl:
snprintf(path->long_name, name_len, "%s",
w->kcontrols[i].name);
break;
break;
}

path->long_name[name_len - 1] = '\0';
Expand Down

0 comments on commit 07495f3

Please sign in to comment.