Skip to contentSkip to conversation

ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link()

PATCH In review Wang Yufen 3 participants 3 messages Dec 5, 2022 – Dec 7, 2022

Subsystems (3)
lore
Share & tools
lore

Wang Yufen

author
#0 lore raw

PATCH 1/1 ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link()

The of_get_next_child() returns a node with refcount incremented, and decrements the refcount of prev. So in the error path of the while loop, of_node_put() needs be called for cpu_ep.

Fixes fce9b90c1ab7 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")
---
 sound/soc/generic/audio-graph-card.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +3 -1
index fe7cf97..5daa824 100644
@@ -485,8 +485,10 @@ static int __graph_for_each_link(struct asoc_simple_priv *priv,
 			of_node_put(codec_ep);
 			of_node_put(codec_port);
 
-			if (ret < 0)
+			if (ret < 0) {
+				of_node_put(cpu_ep);
 				return ret;
+			}
 
 			codec_port_old = codec_port;
 		}
Signature · 1 line
1.8.3.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi

Quoted 7 lines

The of_get_next_child() returns a node with refcount incremented, and decrements the refcount of prev. So in the error path of the while loop, of_node_put() needs be called for cpu_ep.

Fixes fce9b90c1ab7 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")

---

Quoted 23 lines
 sound/soc/generic/audio-graph-card.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +3 -1
index fe7cf97..5daa824 100644
@@ -485,8 +485,10 @@ static int __graph_for_each_link(struct asoc_simple_priv *priv,
 			of_node_put(codec_ep);
 			of_node_put(codec_port);
 
-			if (ret < 0)
+			if (ret < 0) {
+				of_node_put(cpu_ep);
 				return ret;
+			}
 
 			codec_port_old = codec_port;
 		}
Signature · 1 line
1.8.3.1

Thank you for your help !!

Best regards
---
Kuninori Morimoto

maintainer
#2 lore raw
In reply to Wang Yufen
Quoted 5 lines · Wang Yufen

The of_get_next_child() returns a node with refcount incremented, and decrements the refcount of prev. So in the error path of the while loop, of_node_put() needs be called for cpu_ep.

Applied to

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

Thanks!

[1/1] ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link()

      commit: 8ab2d12c726f0fde0692fa5d81d8019b3dcd62d0

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