Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: audio-graph-card2: Release multi-link ports references
@ 2026-11-19  7:58 Zhu Jun
  2026-11-19  8:08 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-19  7:58 UTC (permalink / raw)
  To: broonie; +Cc: lgirdwood, kuninori.morimoto.gx, linux-sound, linux-kernel,
	Zhu Jun

port_to_ports() returns a referenced ports node. graph_counter() drops
the pointer after counting the ports, while graph_parse_node_multi_nm()
compares it with the expected codec ports node and discards it. The
references remain held after card parsing, including across reprobes.

Use the existing device_node cleanup pattern at both call sites, so
the temporary references are released when their scopes end.

Fixes: e2de6808df4a ("ASoC: audio-graph-card2: add CPU:Codec = N:M support")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 sound/soc/generic/audio-graph-card2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 4708bbba1a3c..210c789d4b7c 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -559,9 +559,10 @@ static int graph_parse_node_multi_nm(struct simple_util_priv *priv,
 
 		struct device_node *mcodec_ep_n __free(device_node) = of_graph_get_remote_endpoint(mcpu_ep_n);
 		struct device_node *mcodec_port __free(device_node) = ep_to_port(mcodec_ep_n);
+		struct device_node *ports __free(device_node) = port_to_ports(mcodec_port);
 
 		ret = -EINVAL;
-		if (mcodec_ports != port_to_ports(mcodec_port))
+		if (mcodec_ports != ports)
 			break;
 
 		for_each_of_graph_port(mcodec_ports, mcodec_port_i) {
@@ -1117,7 +1118,7 @@ static int graph_counter(struct device_node *lnk)
 	 * ignore first lnk part
 	 */
 	if (graph_lnk_is_multi(lnk)) {
-		struct device_node *ports = port_to_ports(lnk);
+		struct device_node *ports __free(device_node) = port_to_ports(lnk);
 
 		/*
 		 * CPU/Codec = N:M case has many endpoints.



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19  8:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  7:58 [PATCH] ASoC: audio-graph-card2: Release multi-link ports references Zhu Jun
2026-11-19  8:08 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox