diff mbox series

ASoC: audio-graph-card2: call of_node_get() before of_get_next_child()

Message ID 875xvmqzs8.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit e54f128b0c2fe543816941342e085e21f49c5b6c
Headers show
Series ASoC: audio-graph-card2: call of_node_get() before of_get_next_child() | expand

Commit Message

Kuninori Morimoto May 10, 2024, 12:24 a.m. UTC
commit c6f597bc598a8 ("ASoC: audio-graph-card2: remove unneeded
of_node_get()") removed of_node_get(), but it need to keep original
reference, so of_node_get() itself is needed.

Because of_get_next_child() will call of_node_put() inside, if the
reference count dropped to zero, then of_node_get() after that will be
use afer free. Need to call of_node_get() *before* that.

Fixes: c6f597bc598a ("ASoC: audio-graph-card2: remove unneeded of_node_get()")
Link: https://lore.kernel.org/r/f930862e-9d30-4ea3-b3e7-b4b4f411f6d1@moroto.mountain
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Carpenter May 10, 2024, 7:45 a.m. UTC | #1
On Fri, May 10, 2024 at 12:24:55AM +0000, Kuninori Morimoto wrote:
> commit c6f597bc598a8 ("ASoC: audio-graph-card2: remove unneeded
> of_node_get()") removed of_node_get(), but it need to keep original
> reference, so of_node_get() itself is needed.
> 
> Because of_get_next_child() will call of_node_put() inside, if the
> reference count dropped to zero, then of_node_get() after that will be
> use afer free. Need to call of_node_get() *before* that.
> 
> Fixes: c6f597bc598a ("ASoC: audio-graph-card2: remove unneeded of_node_get()")
> Link: https://lore.kernel.org/r/f930862e-9d30-4ea3-b3e7-b4b4f411f6d1@moroto.mountain
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

Thanks!

regards,
dan carpenter
Mark Brown May 10, 2024, 1:18 p.m. UTC | #2
On Fri, 10 May 2024 00:24:55 +0000, Kuninori Morimoto wrote:
> commit c6f597bc598a8 ("ASoC: audio-graph-card2: remove unneeded
> of_node_get()") removed of_node_get(), but it need to keep original
> reference, so of_node_get() itself is needed.
> 
> Because of_get_next_child() will call of_node_put() inside, if the
> reference count dropped to zero, then of_node_get() after that will be
> use afer free. Need to call of_node_get() *before* that.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: audio-graph-card2: call of_node_get() before of_get_next_child()
      commit: e54f128b0c2fe543816941342e085e21f49c5b6c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index c4d52fadebb6..81e84095107e 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -1197,7 +1197,7 @@  static int graph_count_c2c(struct simple_util_priv *priv,
 {
 	struct device_node *ports = of_get_parent(lnk);
 	struct device_node *port0 = lnk;
-	struct device_node *port1 = of_get_next_child(ports, lnk);
+	struct device_node *port1 = of_get_next_child(ports, of_node_get(lnk));
 	struct device_node *ep0 = port_to_endpoint(port0);
 	struct device_node *ep1 = port_to_endpoint(port1);
 	struct device_node *codec0 = of_graph_get_remote_port(ep0);