[5/5] ASoC: rsnd: fix SSIU node reference leak in rsnd_dma_of_path

Message ID 20261107160827257FwoXZMjcThgcfD-ZPfKsk@zte.com.cn (mailing list archive)
State New
Headers
Series ASoC: fix error-path leaks and a NULL dereference |

Commit Message

shao.mingyin@zte.com.cn Nov. 7, 2026, 8:08 a.m. UTC
From: Shao Mingyin <shao.mingyin@zte.com.cn>

rsnd_ssiu_of_node() returns the child node obtained by
of_get_child_by_name(), which holds a reference.  rsnd_dma_of_path()
only tests that node and never drops the reference, so every DMA path
setup leaks the SSIU node.

Put the node after the SSIU branch has used it.

Fixes: 4e7788fb8018 ("ASoC: rsnd: add SSIU BUSIF support")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
  

Comments

Kuninori Morimoto Nov. 9, 2026, 2:03 a.m. UTC | #1
Hi

> From: Shao Mingyin <shao.mingyin@zte.com.cn>
> 
> rsnd_ssiu_of_node() returns the child node obtained by
> of_get_child_by_name(), which holds a reference.  rsnd_dma_of_path()
> only tests that node and never drops the reference, so every DMA path
> setup leaks the SSIU node.
> 
> Put the node after the SSIU branch has used it.
> 
> Fixes: 4e7788fb8018 ("ASoC: rsnd: add SSIU BUSIF support")
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thank you for your help !!

Best regards
---
Kuninori Morimoto
  

Patch

diff --git a/sound/soc/renesas/rcar/dma.c b/sound/soc/renesas/rcar/dma.c
index 793dd4adbe5c..ece23ef5e56c 100644
--- a/sound/soc/renesas/rcar/dma.c
+++ b/sound/soc/renesas/rcar/dma.c
@@ -791,6 +791,7 @@  static void rsnd_dma_of_path(struct rsnd_mod *this,
 	struct rsnd_mod *mod_start, *mod_end;
 	struct rsnd_priv *priv = rsnd_mod_to_priv(this);
 	struct device *dev = rsnd_priv_to_dev(priv);
+	struct device_node *ssiu_np;
 	int nr, i, idx;
 
 	/*
@@ -803,13 +804,15 @@  static void rsnd_dma_of_path(struct rsnd_mod *this,
 	 *	rsnd_ssiu_dma_req()
 	 *	rsnd_ssi_dma_req()
 	 */
-	if (rsnd_ssiu_of_node(priv)) {
+	ssiu_np = rsnd_ssiu_of_node(priv);
+	if (ssiu_np) {
 		struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
 
 		/* use SSIU */
 		ssi = ssiu;
 		if (this == rsnd_io_to_mod_ssi(io))
 			this = ssiu;
+		of_node_put(ssiu_np);
 	} else {
 		/* keep compatible, use SSI */
 		ssi = rsnd_io_to_mod_ssi(io);