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 5/6] ASoC: qcom: Fix of-node refcount unbalance in qcom_snd_parse_of()
Date: Tue, 19 Feb 2019 16:46:51 +0100 [thread overview]
Message-ID: <20190219154652.13644-6-tiwai@suse.de> (raw)
In-Reply-To: <20190219154652.13644-1-tiwai@suse.de>
Although qcom_snd_parse_of() tries to manage the of-node refcount,
there are still a few places that lead to the unblanced refcount in
the error code path. Namely,
- for_each_child_of_node() needs to unreference the iterator node if
aborting the loop in the middle,
- cpu, codec and platform node objects have to be unreferenced at each
iteration,
- platform and codec node objects have to be referred before jumping
to the error handling code that unreference them unconditionally.
This patch tries to address these by moving the assignment of platform
and codec node objects to the beginning of the loop and adding the
of_node_put() calls adequately.
Fixes: c25e295cd77b ("ASoC: qcom: Add support to parse common audio device nodes")
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/common.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 4715527054e5..5661025e8cec 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -42,6 +42,9 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
link = card->dai_link;
for_each_child_of_node(dev->of_node, np) {
cpu = of_get_child_by_name(np, "cpu");
+ platform = of_get_child_by_name(np, "platform");
+ codec = of_get_child_by_name(np, "codec");
+
if (!cpu) {
dev_err(dev, "Can't find cpu DT node\n");
ret = -EINVAL;
@@ -63,8 +66,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
goto err;
}
- platform = of_get_child_by_name(np, "platform");
- codec = of_get_child_by_name(np, "codec");
if (codec && platform) {
link->platform_of_node = of_parse_phandle(platform,
"sound-dai",
@@ -100,10 +101,15 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
link->dpcm_capture = 1;
link->stream_name = link->name;
link++;
+
+ of_node_put(cpu);
+ of_node_put(codec);
+ of_node_put(platform);
}
return 0;
err:
+ of_node_put(np);
of_node_put(cpu);
of_node_put(codec);
of_node_put(platform);
--
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 ` [PATCH 4/6] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of() Takashi Iwai
2019-02-20 17:52 ` Applied "ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of()" 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 qcom_snd_parse_of()" " 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-6-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;
as well as URLs for NNTP newsgroup(s).