* [PATCH net] net: cirrus: ep93xx: fix the probe error path
@ 2026-11-30 22:57 Arina Kharlamova via B4 Relay
2026-11-30 23:00 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-11-30 22:57 UTC (permalink / raw)
To: Hartley Sweeten, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Guenter Roeck, Miquel Raynal,
Linus Walleij, Krzysztof Kozlowski, Jeff Garzik,
Lennert Buytenhek
Cc: Andy Shevchenko, Vinod Koul, Nikita Shubin, Arnd Bergmann, netdev,
Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
ep93xx_eth_probe() maps the registers before it looks up the PHY and
allocates the net_device. The early returns for a missing "phy-handle"
or "reg" do not unmap them. The error path calls ep93xx_eth_remove(),
which does nothing when the allocation failed, and does not unmap the
registers when reserving the memory region failed, because the mapping
is stored in the private data only after that.
ep93xx_eth_remove() also unregisters the net_device even when
register_netdev() was never called or failed: unregister_netdevice
warns about a device that never was registered, or hits its BUG_ON()
when registration failed after the device was marked unregistered.
Unwind in probe instead: release the region, free the net_device and
unmap the registers, in that order and only as far as probe got.
Fixes: 770e709e38bf ("net: cirrus: add DT support for Cirrus EP93xx")
Fixes: 1d22e05df818 ("[PATCH] Cirrus Logic ep93xx ethernet driver")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
Found by the spec2patch formal prover, with the help of an AI coding
assistant (Claude); I reviewed the analysis and the fix.
---
drivers/net/ethernet/cirrus/ep93xx_eth.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index a4972457edd9..8f893ed441d2 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -789,18 +789,22 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, -EIO, "Failed to ioremap ethernet registers\n");
np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
- if (!np)
- return dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n");
+ if (!np) {
+ err = dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n");
+ goto err_unmap;
+ }
err = of_property_read_u32(np, "reg", &phy_id);
of_node_put(np);
- if (err)
- return dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n");
+ if (err) {
+ err = dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n");
+ goto err_unmap;
+ }
dev = alloc_etherdev(sizeof(struct ep93xx_priv));
if (dev == NULL) {
err = -ENOMEM;
- goto err_out;
+ goto err_unmap;
}
memcpy_fromio(addr, base_addr + 0x50, ETH_ALEN);
@@ -821,7 +825,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
if (ep->res == NULL) {
dev_err(&pdev->dev, "Could not reserve memory region\n");
err = -ENOMEM;
- goto err_out;
+ goto err_free_netdev;
}
ep->base_addr = base_addr;
@@ -841,7 +845,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
err = register_netdev(dev);
if (err) {
dev_err(&pdev->dev, "Failed to register netdev\n");
- goto err_out;
+ goto err_release;
}
printk(KERN_INFO "%s: ep93xx on-chip ethernet, IRQ %d, %pM\n",
@@ -849,8 +853,12 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
return 0;
-err_out:
- ep93xx_eth_remove(pdev);
+err_release:
+ release_mem_region(mem->start, resource_size(mem));
+err_free_netdev:
+ free_netdev(dev);
+err_unmap:
+ iounmap(base_addr);
return err;
}
---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-v04-c14ecf1e0728
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: cirrus: ep93xx: fix the probe error path
2026-11-30 22:57 [PATCH net] net: cirrus: ep93xx: fix the probe error path Arina Kharlamova via B4 Relay
@ 2026-11-30 23:00 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-30 23:00 UTC (permalink / raw)
To: Arina Kharlamova
Cc: Hartley Sweeten, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Guenter Roeck, Miquel Raynal,
Linus Walleij, Krzysztof Kozlowski, Jeff Garzik,
Lennert Buytenhek, Andy Shevchenko, Vinod Koul, Nikita Shubin,
Arnd Bergmann, netdev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 23:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:57 [PATCH net] net: cirrus: ep93xx: fix the probe error path Arina Kharlamova via B4 Relay
2026-11-30 23:00 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox