All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Borneo <borneo.antonio@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org
Cc: Antonio Borneo <borneo.antonio@gmail.com>,
	linux-kernel@vger.kernel.org, Wei Xu <xuwei5@hisilicon.com>,
	John Stultz <john.stultz@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH v2 2/3] ASoC: soc-core: fix unbalanced of_node_get()/of_node_put()
Date: Fri, 28 Jul 2017 01:26:11 +0200	[thread overview]
Message-ID: <20170727232612.23543-3-antonio.borneo@st.com> (raw)
In-Reply-To: <20170727232612.23543-1-antonio.borneo@st.com>
In-Reply-To: <20170725214952.6491-1-borneo.antonio@gmail.com>

From: Antonio Borneo <borneo.antonio@gmail.com>

On Hikey target board, enabling CONFIG_OF_DYNAMIC triggers several
errors at kernel boot, like the following one
OF: ERROR: Bad of_node_put() on /soc/i2s@f7118000/ports/port@0/endpoint
each followed by stack dump.

of_graph_get_port_parent() walks through the parents looking for a
node named "ports". At each step it uses of_get_next_parent() that
drops the current node with of_node_put().
Avoid dropping the initial node by calling of_node_get() before
of_graph_get_port_parent().

Tested with kernel v4.13-rc2 with hikey_defconfig taken from
https://git.linaro.org/people/john.stultz/android-dev.git
branch dev/hikey-mainline-WIP

This fixes commit a180e8b98843 ("ASoC: add snd_soc_get_dai_id()
function").

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
---
To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
To: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.com>
To: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 921622a..a0f39de 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4087,6 +4087,11 @@ int snd_soc_get_dai_id(struct device_node *ep)
 	struct device_node *node;
 	int ret;
 
+	/*
+	 * of_graph_get_port_parent() will call
+	 * of_node_put(). So, call of_node_get() here
+	 */
+	of_node_get(ep);
 	node = of_graph_get_port_parent(ep);
 
 	/*
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: borneo.antonio@gmail.com (Antonio Borneo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] ASoC: soc-core: fix unbalanced of_node_get()/of_node_put()
Date: Fri, 28 Jul 2017 01:26:11 +0200	[thread overview]
Message-ID: <20170727232612.23543-3-antonio.borneo@st.com> (raw)
In-Reply-To: <20170727232612.23543-1-antonio.borneo@st.com>

From: Antonio Borneo <borneo.antonio@gmail.com>

On Hikey target board, enabling CONFIG_OF_DYNAMIC triggers several
errors at kernel boot, like the following one
OF: ERROR: Bad of_node_put() on /soc/i2s at f7118000/ports/port at 0/endpoint
each followed by stack dump.

of_graph_get_port_parent() walks through the parents looking for a
node named "ports". At each step it uses of_get_next_parent() that
drops the current node with of_node_put().
Avoid dropping the initial node by calling of_node_get() before
of_graph_get_port_parent().

Tested with kernel v4.13-rc2 with hikey_defconfig taken from
https://git.linaro.org/people/john.stultz/android-dev.git
branch dev/hikey-mainline-WIP

This fixes commit a180e8b98843 ("ASoC: add snd_soc_get_dai_id()
function").

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
---
To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
To: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.com>
To: alsa-devel at alsa-project.org
Cc: linux-kernel at vger.kernel.org
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 921622a..a0f39de 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4087,6 +4087,11 @@ int snd_soc_get_dai_id(struct device_node *ep)
 	struct device_node *node;
 	int ret;
 
+	/*
+	 * of_graph_get_port_parent() will call
+	 * of_node_put(). So, call of_node_get() here
+	 */
+	of_node_get(ep);
 	node = of_graph_get_port_parent(ep);
 
 	/*
-- 
1.9.1

  parent reply	other threads:[~2017-07-27 23:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 21:49 [PATCH] ASoC: fix balance of of_node_get()/of_node_put() Antonio Borneo
2017-07-25 21:49 ` Antonio Borneo
2017-07-26  1:42 ` [alsa-devel] " Kuninori Morimoto
2017-07-26  1:42   ` Kuninori Morimoto
2017-07-26 11:37 ` Mark Brown
2017-07-26 11:37   ` Mark Brown
2017-07-27 23:20   ` Antonio Borneo
2017-07-27 23:20     ` Antonio Borneo
2017-07-27 23:20     ` Antonio Borneo
2017-07-27 23:26 ` [PATCH v2 0/3] ASoC: fix unbalanced of_node_get()/of_node_put() Antonio Borneo
2017-07-27 23:26   ` Antonio Borneo
2017-07-27 23:26   ` Antonio Borneo
2017-07-28 10:07   ` Mark Brown
2017-07-28 10:07     ` Mark Brown
2017-07-30 20:34     ` Antonio Borneo
2017-07-30 20:34       ` Antonio Borneo
2017-07-30 20:34       ` Antonio Borneo
2017-07-27 23:26 ` [PATCH v2 1/3] ASoC: fix use of of_node_put() in of_for_each_phandle() loops Antonio Borneo
2017-07-27 23:26   ` Antonio Borneo
2017-07-27 23:26 ` Antonio Borneo [this message]
2017-07-27 23:26   ` [PATCH v2 2/3] ASoC: soc-core: fix unbalanced of_node_get()/of_node_put() Antonio Borneo
2017-07-27 23:26 ` [PATCH v2 3/3] ASoC: simple-card-utils: " Antonio Borneo
2017-07-27 23:26   ` Antonio Borneo

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=20170727232612.23543-3-antonio.borneo@st.com \
    --to=borneo.antonio@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=john.stultz@linaro.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=xuwei5@hisilicon.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.