* [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
@ 2025-09-18 9:48 Dan Carpenter
2025-09-18 16:27 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-09-18 9:48 UTC (permalink / raw)
To: Roger Quadros
Cc: MD Danish Anwar, Parvathi Pudi, Roger Quadros,
Mohan Reddy Putluru, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Basharath Hussain Khaja,
Andrew F. Davis, linux-arm-kernel, netdev, linux-kernel,
kernel-janitors
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
2025-09-18 9:48 [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe() Dan Carpenter
@ 2025-09-18 16:27 ` Simon Horman
2025-09-19 14:04 ` Jakub Kicinski
2025-09-20 0:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-09-18 16:27 UTC (permalink / raw)
To: Dan Carpenter
Cc: Roger Quadros, MD Danish Anwar, Parvathi Pudi, Roger Quadros,
Mohan Reddy Putluru, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Basharath Hussain Khaja,
Andrew F. Davis, linux-arm-kernel, netdev, linux-kernel,
kernel-janitors
On Thu, Sep 18, 2025 at 12:48:26PM +0300, Dan Carpenter wrote:
> 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>
Thanks Dan.
I'm pretty sure I reviewed this code at some point.
Sorry for not noticing this problem then.
Reviewed-by: Simon Horman <horms@kernel.org>
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
2025-09-18 9:48 [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe() Dan Carpenter
2025-09-18 16:27 ` Simon Horman
@ 2025-09-19 14:04 ` Jakub Kicinski
2025-09-19 16:26 ` Parvathi Pudi
2025-09-20 0:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-09-19 14:04 UTC (permalink / raw)
To: Roger Quadros, MD Danish Anwar, Parvathi Pudi, Roger Quadros
Cc: Dan Carpenter, Mohan Reddy Putluru, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Basharath Hussain Khaja,
Andrew F. Davis, linux-arm-kernel, netdev, linux-kernel,
kernel-janitors
On Thu, 18 Sep 2025 12:48:26 +0300 Dan Carpenter wrote:
> 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.
icssm maintainers - please review
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
2025-09-19 14:04 ` Jakub Kicinski
@ 2025-09-19 16:26 ` Parvathi Pudi
0 siblings, 0 replies; 5+ messages in thread
From: Parvathi Pudi @ 2025-09-19 16:26 UTC (permalink / raw)
To: kuba, Dan Carpenter
Cc: rogerq, danishanwar, parvathi, rogerq, pmohan, andrew+netdev,
davem, edumazet, pabeni, basharath, afd, linux-arm-kernel, netdev,
linux-kernel, kernel-janitors
Hi,
> On Thu, 18 Sep 2025 12:48:26 +0300 Dan Carpenter wrote:
>> 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.
>
> icssm maintainers - please review
Yes you are correct. This got missed somehow sorry about that.
Now the error return is gracefully exiting by freeing the resources.
Reviewed-by: Parvathi Pudi <parvathi@couthit.com>
Thanks and Regards,
Parvathi.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe()
2025-09-18 9:48 [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe() Dan Carpenter
2025-09-18 16:27 ` Simon Horman
2025-09-19 14:04 ` Jakub Kicinski
@ 2025-09-20 0:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-20 0:10 UTC (permalink / raw)
To: Dan Carpenter
Cc: rogerq, danishanwar, parvathi, rogerq, pmohan, andrew+netdev,
davem, edumazet, kuba, pabeni, basharath, afd, linux-arm-kernel,
netdev, linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 18 Sep 2025 12:48:26 +0300 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net-next] net: ti: icssm-prueth: unwind cleanly in probe()
https://git.kernel.org/netdev/net-next/c/5fc7fa743dbf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-20 0:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 9:48 [PATCH net-next] net: ti: icssm-prueth: unwind cleanly in probe() Dan Carpenter
2025-09-18 16:27 ` Simon Horman
2025-09-19 14:04 ` Jakub Kicinski
2025-09-19 16:26 ` Parvathi Pudi
2025-09-20 0:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).