From: sashiko-bot@kernel.org
To: "Zhu Jun" <zhujun2@cmss.chinamobile.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: audio-graph-card2: Release multi-link ports references
Date: Thu, 19 Nov 2026 08:08:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-222644@kernel.org> (raw)
In-Reply-To: <20261119075815.50155-1-zhujun2@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ASoC: audio-graph-card2: double of_node_put() in
graph_link_init() [1]
--
commit bb6eb5c362dba929e29a53d648672a0c04801536
Author: Zhu Jun <zhujun2@cmss.chinamobile.com>
ASoC: audio-graph-card2: Release multi-link ports references
This commit uses __free(device_node) to release temporary device_node
references returned by port_to_ports() in graph_parse_node_multi_nm() and
graph_counter().
> diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
> index d2f32a3a5b28d..245a822c33586 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) {
[Severity: Critical]
This problem wasn't introduced by this patch, but in the multi-link node
handling in graph_link_init(), doesn't passing multi_cpu_port and
multi_codec_port to graph_get_next_multi_ep() cause a double of_node_put()
on port_cpu and port_codec [1]?
sound/soc/generic/audio-graph-card2.c:graph_link_init() {
struct device_node *port_cpu = ep_to_port(ep_cpu);
struct device_node *port_codec = ep_to_port(ep_codec);
...
if (graph_lnk_is_multi(port_cpu)) {
multi_cpu_port = port_cpu;
ep_cpu = graph_get_next_multi_ep(&multi_cpu_port, multi_cpu_port_idx++);
of_node_put(port_cpu);
port_cpu = ep_to_port(ep_cpu);
}
...
if (graph_lnk_is_multi(port_codec)) {
multi_codec_port = port_codec;
ep_codec = graph_get_next_multi_ep(&multi_codec_port, multi_codec_port_idx++);
of_node_put(port_codec);
port_codec = ep_to_port(ep_codec);
}
}
graph_get_next_multi_ep() calls of_node_put(*port) before replacing *port
with of_graph_get_port_by_id(ports, idx). Because port_cpu and port_codec
still hold the initial node pointers acquired by ep_to_port(), the
subsequent of_node_put(port_cpu) and of_node_put(port_codec) calls in
graph_link_init() drop those same references a second time, underflowing
the device_node reference counts and leading to use-after-free.
[1] https://sashiko.dev/#/bug/linux-cfb81a5c-4dcd-4040-99a5-4886fa74927e
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119075815.50155-1-zhujun2@cmss.chinamobile.com?part=1
prev parent reply other threads:[~2026-11-19 8:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=sashiko-outbox-222644@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhujun2@cmss.chinamobile.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox