net: cpsw_new: unregister devlink on port registration failure
Subsystems (3)
PATCH v2 1/1 net: cpsw_new: unregister devlink on port registration failure
cpsw_probe() registers devlink before registering the CPSW ports.
If cpsw_register_ports() fails, the error path only unregisters the notifiers and then releases the lower level resources. It does not undo the successful cpsw_register_devlink() call, leaving the devlink instance and its parameters registered after probe has failed.
Add a devlink cleanup label for the path where devlink registration has already succeeded, and use it when port registration fails.
---
v2:
- Updated the subject for net-next.
- Dropped the Fixes tag.
drivers/net/ethernet/ti/cpsw_new.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_new.c +3 -1
@@ -2050,7 +2050,7 @@ static int cpsw_probe(struct platform_device *pdev) ret =cpsw_register_ports (cpsw);if (ret) - goto clean_unregister_notifiers; + goto clean_unregister_devlink; dev_notice(dev, "initialized (regs %pa, pool size %d) hw_ver:%08X %d.%d (%d)\n", &ss_res->start, descs_pool_size,
@@ -2062,6 +2062,8 @@ static int cpsw_probe(struct platform_device *pdev)return 0 ; +clean_unregister_devlink: +cpsw_unregister_devlink (cpsw); clean_unregister_notifiers:cpsw_unregister_notifiers (cpsw); clean_cpts:
Signature · 1 line
2.43.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 4 Jun 2026 12:31:15 +0800 you wrote:
cpsw_probe()registers devlink before registering the CPSW ports.If
cpsw_register_ports()fails, the error path only unregisters the notifiers and then releases the lower level resources. It does not undo the successfulcpsw_register_devlink()call, leaving the devlink instance and its parameters registered after probe has failed.[...]
Here is the summary with links:
- [net-next,v2] net: cpsw_new: unregister devlink on port registration failure
https://git.kernel.org/netdev/net-next/c/b64f763b6074
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html