From: Dan Carpenter <dan.carpenter@linaro.org>
To: Roger Quadros <rogerq@ti.com>
Cc: MD Danish Anwar <danishanwar@ti.com>,
Parvathi Pudi <parvathi@couthit.com>,
Roger Quadros <rogerq@kernel.org>,
Mohan Reddy Putluru <pmohan@couthit.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Basharath Hussain Khaja <basharath@couthit.com>,
"Andrew F. Davis" <afd@ti.com>,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
Date: Thu, 18 Sep 2025 12:48:26 +0300 [thread overview]
Message-ID: <aMvVagz8aBRxMvFn@stanley.mountain> (raw)
This error handling triggers a Smatch warning:
drivers/net/ethernet/ti/icssm/icssm_prueth.c:1574 icssm_prueth_probe()
warn: 'prueth->pru1' is an error pointer or valid
The warning is harmless because the pru_rproc_put() function has an
IS_ERR_OR_NULL() check built in. However, there is a small bug if
syscon_regmap_lookup_by_phandle() fails. In that case we should call
of_node_put() on eth0_node and eth1_node.
It's a little bit easier to re-write this code to only free things which
we know have been allocated successfully.
Fixes: 511f6c1ae093 ("net: ti: icssm-prueth: Adds ICSSM Ethernet driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/ethernet/ti/icssm/icssm_prueth.c | 30 +++++++++-----------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
index 65d0b792132d..293b7af04263 100644
--- a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
+++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
@@ -1390,7 +1390,8 @@ static int icssm_prueth_probe(struct platform_device *pdev)
prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt");
if (IS_ERR(prueth->mii_rt)) {
dev_err(dev, "couldn't get mii-rt syscon regmap\n");
- return -ENODEV;
+ ret = PTR_ERR(prueth->mii_rt);
+ goto put_eth;
}
if (eth0_node) {
@@ -1398,7 +1399,7 @@ static int icssm_prueth_probe(struct platform_device *pdev)
if (IS_ERR(prueth->pru0)) {
ret = PTR_ERR(prueth->pru0);
dev_err_probe(dev, ret, "unable to get PRU0");
- goto put_pru;
+ goto put_eth;
}
}
@@ -1407,7 +1408,7 @@ static int icssm_prueth_probe(struct platform_device *pdev)
if (IS_ERR(prueth->pru1)) {
ret = PTR_ERR(prueth->pru1);
dev_err_probe(dev, ret, "unable to get PRU1");
- goto put_pru;
+ goto put_pru0;
}
}
@@ -1415,7 +1416,7 @@ static int icssm_prueth_probe(struct platform_device *pdev)
if (IS_ERR(pruss)) {
ret = PTR_ERR(pruss);
dev_err(dev, "unable to get pruss handle\n");
- goto put_pru;
+ goto put_pru1;
}
prueth->pruss = pruss;
@@ -1569,18 +1570,15 @@ static int icssm_prueth_probe(struct platform_device *pdev)
}
pruss_put(prueth->pruss);
-put_pru:
- if (eth1_node) {
- if (prueth->pru1)
- pru_rproc_put(prueth->pru1);
- of_node_put(eth1_node);
- }
-
- if (eth0_node) {
- if (prueth->pru0)
- pru_rproc_put(prueth->pru0);
- of_node_put(eth0_node);
- }
+put_pru1:
+ if (eth1_node)
+ pru_rproc_put(prueth->pru1);
+put_pru0:
+ if (eth0_node)
+ pru_rproc_put(prueth->pru0);
+put_eth:
+ of_node_put(eth1_node);
+ of_node_put(eth0_node);
return ret;
}
--
2.51.0
next reply other threads:[~2025-09-18 9:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 9:48 Dan Carpenter [this message]
2025-09-18 16:27 ` [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe() Simon Horman
2025-09-19 14:04 ` Jakub Kicinski
2025-09-19 16:26 ` Parvathi Pudi
2025-09-20 0:10 ` patchwork-bot+netdevbpf
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=aMvVagz8aBRxMvFn@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=afd@ti.com \
--cc=andrew+netdev@lunn.ch \
--cc=basharath@couthit.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parvathi@couthit.com \
--cc=pmohan@couthit.com \
--cc=rogerq@kernel.org \
--cc=rogerq@ti.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 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.