enum snd_soc_dapm_direction dir;
struct snd_soc_dapm_widget *w;
const char *prefix;
- int ret;
+ int ret = -ENOMEM;
if ((w = dapm_cnew_widget(widget)) == NULL)
- return ERR_PTR(-ENOMEM);
+ goto cnew_failed;
+
+ prefix = soc_dapm_prefix(dapm);
+ if (prefix)
+ w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
+ else
+ w->name = kstrdup_const(widget->name, GFP_KERNEL);
+ if (!w->name)
+ goto name_failed;
switch (w->id) {
case snd_soc_dapm_regulator_supply:
break;
}
- prefix = soc_dapm_prefix(dapm);
- if (prefix)
- w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
- else
- w->name = kstrdup_const(widget->name, GFP_KERNEL);
- if (w->name == NULL) {
- kfree_const(w->sname);
- kfree(w);
- return ERR_PTR(-ENOMEM);
- }
-
switch (w->id) {
case snd_soc_dapm_mic:
w->is_ep = SND_SOC_DAPM_EP_SOURCE;
if (ret != -EPROBE_DEFER)
dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n",
w->name, ret);
-
+ kfree_const(w->name);
+name_failed:
kfree_const(w->sname);
kfree(w);
+cnew_failed:
return ERR_PTR(ret);
}