From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org,
Banajit Goswami <bgoswami@codeaurora.org>,
Patrick Lai <plai@codeaurora.org>
Subject: [PATCH 4/6] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of()
Date: Tue, 19 Feb 2019 16:46:50 +0100 [thread overview]
Message-ID: <20190219154652.13644-5-tiwai@suse.de> (raw)
In-Reply-To: <20190219154652.13644-1-tiwai@suse.de>
The apq8016 driver leaves the of-node refcount at aborting from the
loop of for_each_child_of_node() in the error path. Not only the
iterator node of for_each_child_of_node(), the children nodes referred
from it for codec and cpu have to be properly unreferenced.
Fixes: bdb052e81f62 ("ASoC: qcom: add apq8016 sound card support")
Cc: Patrick Lai <plai@codeaurora.org>
Cc: Banajit Goswami <bgoswami@codeaurora.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
Only compile-tested. Please review carefully. Thanks!
sound/soc/qcom/apq8016_sbc.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
index 1dd23bba1bed..4b559932adc3 100644
--- a/sound/soc/qcom/apq8016_sbc.c
+++ b/sound/soc/qcom/apq8016_sbc.c
@@ -164,41 +164,52 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
if (!cpu || !codec) {
dev_err(dev, "Can't find cpu/codec DT node\n");
- return ERR_PTR(-EINVAL);
+ ret = -EINVAL;
+ goto error;
}
link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
if (!link->cpu_of_node) {
dev_err(card->dev, "error getting cpu phandle\n");
- return ERR_PTR(-EINVAL);
+ ret = -EINVAL;
+ goto error;
}
ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name);
if (ret) {
dev_err(card->dev, "error getting cpu dai name\n");
- return ERR_PTR(ret);
+ goto error;
}
ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
if (ret < 0) {
dev_err(card->dev, "error getting codec dai name\n");
- return ERR_PTR(ret);
+ goto error;
}
link->platform_of_node = link->cpu_of_node;
ret = of_property_read_string(np, "link-name", &link->name);
if (ret) {
dev_err(card->dev, "error getting codec dai_link name\n");
- return ERR_PTR(ret);
+ goto error;
}
link->stream_name = link->name;
link->init = apq8016_sbc_dai_init;
link++;
+
+ of_node_put(cpu);
+ of_node_put(codec);
}
return data;
+
+ error:
+ of_node_put(np);
+ of_node_put(cpu);
+ of_node_put(codec);
+ return ERR_PTR(ret);
}
static const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = {
--
2.16.4
next prev parent reply other threads:[~2019-02-19 15:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 15:46 [PATCH 0/6] ASoC: Fix of-node refcount unbalance Takashi Iwai
2019-02-19 15:46 ` [PATCH 1/6] ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt() Takashi Iwai
2019-02-20 5:29 ` Nicolin Chen
2019-02-20 12:13 ` Applied "ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt()" to the asoc tree Mark Brown
2019-02-19 15:46 ` [PATCH 2/6] ASoC: simple-card: Fix missing of_node_put() at simple_dai_link_of() Takashi Iwai
2019-02-20 12:13 ` Applied "ASoC: simple-card: Fix missing of_node_put() at simple_dai_link_of()" to the asoc tree Mark Brown
2019-02-19 15:46 ` [PATCH 3/6] ASoC: simple-card: Fix of-node refcount unbalance in DAI-link parser Takashi Iwai
2019-02-20 12:13 ` Applied "ASoC: simple-card: Fix of-node refcount unbalance in DAI-link parser" to the asoc tree Mark Brown
2019-02-19 15:46 ` Takashi Iwai [this message]
2019-02-20 17:52 ` Applied "ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of()" " Mark Brown
2019-02-19 15:46 ` [PATCH 5/6] ASoC: qcom: Fix of-node refcount unbalance in qcom_snd_parse_of() Takashi Iwai
2019-02-20 17:52 ` Applied "ASoC: qcom: Fix of-node refcount unbalance in qcom_snd_parse_of()" to the asoc tree Mark Brown
2019-02-19 15:46 ` [PATCH 6/6] ASoC: samsung: Fix of-node refcount unbalance in odroid_audio_probe() Takashi Iwai
2019-02-19 16:36 ` Sylwester Nawrocki
2019-02-20 10:40 ` Takashi Iwai
2019-02-20 11:06 ` Sylwester Nawrocki
2019-02-20 0:27 ` [PATCH 0/6] ASoC: Fix of-node refcount unbalance Kuninori Morimoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190219154652.13644-5-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=plai@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox