summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/soc/generic/audio-graph-card2.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 0202ed0ee78e..c5ada1f83881 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -1303,11 +1303,11 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev,
struct graph2_custom_hooks *hooks)
{
struct snd_soc_card *card = simple_priv_to_card(priv);
- int ret;
+ int ret = -ENOMEM;
struct link_info *li __free(kfree) = kzalloc_obj(*li);
if (!li)
- return -ENOMEM;
+ goto end;
card->probe = graph_util_card_probe;
card->owner = THIS_MODULE;
@@ -1316,33 +1316,33 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev,
if ((hooks) && (hooks)->hook_pre) {
ret = (hooks)->hook_pre(priv);
if (ret < 0)
- goto err;
+ goto end;
}
ret = graph_for_each_link(priv, hooks, li, graph_count);
if (!li->link)
ret = -EINVAL;
if (ret < 0)
- goto err;
+ goto end;
ret = simple_util_init_priv(priv, li);
if (ret < 0)
- goto err;
+ goto end;
priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
if (IS_ERR(priv->pa_gpio)) {
ret = PTR_ERR(priv->pa_gpio);
dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
- goto err;
+ goto end;
}
ret = simple_util_parse_widgets(card, NULL);
if (ret < 0)
- goto err;
+ goto end;
ret = simple_util_parse_routing(card, NULL);
if (ret < 0)
- goto err;
+ goto end;
memset(li, 0, sizeof(*li));
ret = graph_for_each_link(priv, hooks, li, graph_link);
@@ -1369,9 +1369,11 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev,
ret = devm_snd_soc_register_card(dev, card);
err:
- if (ret < 0)
- dev_err_probe(dev, ret, "parse error\n");
-
+ if (ret < 0) {
+ simple_util_clean_reference(card);
+ return dev_err_probe(dev, ret, "parse error\n");
+ }
+end:
return graph_ret(priv, ret);
}
EXPORT_SYMBOL_GPL(audio_graph2_parse_of);