From: Dan Carpenter <dan.carpenter@linaro.org>
To: kuninori.morimoto.gx@renesas.com
Cc: linux-sound@vger.kernel.org
Subject: [bug report] ASoC: audio-graph-card2: add Codec2Codec support
Date: Wed, 8 May 2024 18:14:26 +0300 [thread overview]
Message-ID: <f930862e-9d30-4ea3-b3e7-b4b4f411f6d1@moroto.mountain> (raw)
Hello Kuninori Morimoto,
Commit c3a15c92a67b ("ASoC: audio-graph-card2: add Codec2Codec
support") from Oct 12, 2021 (linux-next), leads to the following
Smatch static checker warning:
sound/soc/generic/audio-graph-card2.c:1206 graph_count_c2c()
warn: already decremented on line 1206 'lnk->kobj.kref.refcount.refs.counter'
sound/soc/generic/audio-graph-card2.c
1194 static int graph_count_c2c(struct simple_util_priv *priv,
1195 struct device_node *lnk,
1196 struct link_info *li)
1197 {
1198 struct device_node *ports = of_get_parent(lnk);
1199 struct device_node *port0 = lnk;
1200 struct device_node *port1 = of_get_next_child(ports, lnk);
^^^
This calls of_node_put() on lnk.
1201 struct device_node *ep0 = port_to_endpoint(port0);
1202 struct device_node *ep1 = port_to_endpoint(port1);
1203 struct device_node *codec0 = of_graph_get_remote_port(ep0);
1204 struct device_node *codec1 = of_graph_get_remote_port(ep1);
1205
--> 1206 of_node_get(lnk);
So this of_node_get() undoes the put. But if the reference count
dropped to zero then this would be a use afer free.
1207
1208 /*
1209 * codec2codec {
1210 * ports {
1211 * => lnk: port@0 { endpoint { ... }; };
1212 * port@1 { endpoint { ... }; };
1213 * };
1214 * };
1215 */
1216 /*
1217 * DON'T REMOVE platforms
1218 * see
1219 * simple-card.c :: simple_count_noml()
1220 */
1221 li->num[li->link].cpus =
1222 li->num[li->link].platforms = graph_counter(codec0);
1223
1224 li->num[li->link].codecs = graph_counter(codec1);
1225
1226 of_node_put(ports);
1227 of_node_put(port1);
1228 of_node_put(ep0);
1229 of_node_put(ep1);
1230 of_node_put(codec0);
1231 of_node_put(codec1);
1232
1233 return 0;
1234 }
regards,
dan carpenter
next reply other threads:[~2024-05-08 15:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 15:14 Dan Carpenter [this message]
2024-05-09 0:13 ` [bug report] ASoC: audio-graph-card2: add Codec2Codec support Kuninori Morimoto
2024-05-09 6:49 ` Dan Carpenter
2024-05-09 23:47 ` Kuninori Morimoto
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=f930862e-9d30-4ea3-b3e7-b4b4f411f6d1@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-sound@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.