提交 07495f3e 编写于 作者: M Mark Brown

ASoC: Fix memory allocation for snd_soc_dapm_switch names

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: NJoonyoung Shim <dofmind@gmail.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 b0c5033f
...@@ -332,7 +332,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, ...@@ -332,7 +332,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
* kcontrol name. * kcontrol name.
*/ */
name_len = strlen(w->kcontrols[i].name) + 1; 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); name_len += 1 + strlen(w->name);
path->long_name = kmalloc(name_len, GFP_KERNEL); path->long_name = kmalloc(name_len, GFP_KERNEL);
...@@ -341,15 +341,14 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, ...@@ -341,15 +341,14 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
return -ENOMEM; return -ENOMEM;
switch (w->id) { switch (w->id) {
case snd_soc_dapm_mixer:
default: default:
snprintf(path->long_name, name_len, "%s %s", snprintf(path->long_name, name_len, "%s %s",
w->name, w->kcontrols[i].name); w->name, w->kcontrols[i].name);
break; break;
case snd_soc_dapm_mixer_named_ctl: case snd_soc_dapm_mixer_named_ctl:
snprintf(path->long_name, name_len, "%s", snprintf(path->long_name, name_len, "%s",
w->kcontrols[i].name); w->kcontrols[i].name);
break; break;
} }
path->long_name[name_len - 1] = '\0'; path->long_name[name_len - 1] = '\0';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册