mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 02:01:18 -04:00
net: lan966x: avoid unregistering netdev on register failure
lan966x_probe_port() stores the newly allocated net_device in the
port before calling register_netdev(). If register_netdev() fails,
the probe error path calls lan966x_cleanup_ports(), which sees
port->dev and calls unregister_netdev() for a device that was never
registered.
Destroy the phylink instance created for this port and clear port->dev
before returning the registration error. The common cleanup path now skips
ports without port->dev before reaching the registered netdev cleanup, so
it only handles ports that reached the registered-netdev lifetime.
This also avoids treating an uninitialized FDMA netdev and the failed port
as a NULL == NULL match in the common cleanup path.
Fixes: d28d6d2e37 ("net: lan966x: add port module support")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Link: https://patch.msgid.link/20260506124331.31945-1-mhun512@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f149471f4e
commit
c4f3d6eb1f
@@ -749,11 +749,10 @@ static void lan966x_cleanup_ports(struct lan966x *lan966x)
|
||||
|
||||
for (p = 0; p < lan966x->num_phys_ports; p++) {
|
||||
port = lan966x->ports[p];
|
||||
if (!port)
|
||||
if (!port || !port->dev)
|
||||
continue;
|
||||
|
||||
if (port->dev)
|
||||
unregister_netdev(port->dev);
|
||||
unregister_netdev(port->dev);
|
||||
|
||||
lan966x_xdp_port_deinit(port);
|
||||
if (lan966x->fdma && lan966x->fdma_ndev == port->dev)
|
||||
@@ -873,6 +872,9 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
|
||||
err = register_netdev(dev);
|
||||
if (err) {
|
||||
dev_err(lan966x->dev, "register_netdev failed\n");
|
||||
phylink_destroy(phylink);
|
||||
port->phylink = NULL;
|
||||
port->dev = NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user