net: marvell: prestera: initialize err in prestera_port_sfp_bind
Subsystems (3)
PATCH v2 1/1 net: marvell: prestera: initialize err in prestera_port_sfp_bind
prestera_port_sfp_bind() returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned.
Initialize err to 0 because absence of a matching optional port device tree node is not an error. In that case no phylink is created and port creation should continue with port->phy_link left NULL. Errors from malformed matched nodes and phylink_create() still propagate.
---
v2:
- Add net tree target to the subject.
- Explain why the no-match path returns 0 instead of -ENODEV.
drivers/net/ethernet/marvell/prestera/prestera_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/prestera/prestera_main.c +1 -1
@@ -373,7 +373,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)struct device_node *ports, *node;struct fwnode_handle *fwnode;struct phylink *phy_link; -int err; +int err =0 ;if (!sw->np)return 0 ;
Signature · 1 line
2.51.0
Hi,
Quoted 10 lines · Ruoyu Wang
prestera_port_sfp_bind()returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned.Initialize err to 0 because absence of a matching optional port device tree node is not an error. In that case no phylink is created and port creation should continue with
port->phy_linkleft NULL. Errors from malformed matched nodes andphylink_create()still propagate.Fixes 52323ef75414 ("net: marvell: prestera: add phylink support")Signed-off-by Ruoyu Wang <[email protected]>
Sorry for the grumpiness, but Andrew did ask you to read :
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
and one of the first things it says it to wait 24h before a repost :/
The patch in itself LGTM, so :
Please wait 24h next time,
Maxime
Quoted 41 lines
From: Ruoyu Wang <[email protected]>
Sent: Wednesday, June 17, 2026 10:32 PM
To: Taras Chornyi <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Russell King <[email protected]>; Oleksandr Mazur <[email protected]>; Yevhen Orlov <[email protected]>; [email protected]; [email protected]
Subject: [EXTERNAL] [PATCH net v2] net: marvell: prestera: initialize err inprestera_port_sfp_bind
prestera_port_sfp_bind()returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned. Initialize err to 0 because absence of a matching optional port device tree node is not an error. In
prestera_port_sfp_bind()returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned.Initialize err to 0 because absence of a matching optional port device tree node is not an error. In that case no phylink is created and port creation should continue with
port->phy_linkleft NULL. Errors from malformed matched nodes andphylink_create()still propagate.Fixes 52323ef75414 ("net: marvell: prestera: add phylink support")Signed-off-by Ruoyu Wang <mailto:[email protected]>---
v2:
- Add net tree target to the subject.
- Explain why the no-match path returns 0 instead of-ENODEV.drivers/net/ethernet/marvell/prestera/prestera_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/marvell/prestera/prestera_main.c +1
-2@@ -373,7 +373,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)struct device_node *ports, *node;struct fwnode_handle *fwnode;struct phylink *phy_link; -int err; +int err =0 ;if (!sw->np)return 0 ; --
Quoted 2 lines
2.51.0
prestera_port_sfp_bind() iterates only SFP ports.
Although all currently existing switch boards have at least one SFP uplink port, In theory a manufacturer might produce a switch board without any SFP ports, which will unnecessarily fail this function call, so for resolving this case indeed err should be initialized to zero to make this function return 0 and not an error.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 18 Jun 2026 03:32:28 +0800 you wrote:
prestera_port_sfp_bind()returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned.Initialize err to 0 because absence of a matching optional port device tree node is not an error. In that case no phylink is created and port creation should continue with
port->phy_linkleft NULL. Errors from malformed matched nodes andphylink_create()still propagate.[...]
Here is the summary with links:
- [net,v2] net: marvell: prestera: initialize err in prestera_port_sfp_bind
https://git.kernel.org/netdev/net/c/62b01f72d93c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html