Commit 38b4fe32 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: usb: lan78xx: Connect PHY before registering MAC

As soon as the netdev is registers, the kernel can start using the
interface. If the driver connects the MAC to the PHY after the netdev
is registered, there is a race condition where the interface can be
opened without having the PHY connected.

Change the order to close this race condition.

Fixes: 92571a1a ("lan78xx: Connect phy early")
Reported-by: default avatarDaniel Wagner <dwagner@suse.de>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Tested-by: default avatarDaniel Wagner <dwagner@suse.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e381d2b4
...@@ -3782,10 +3782,14 @@ static int lan78xx_probe(struct usb_interface *intf, ...@@ -3782,10 +3782,14 @@ static int lan78xx_probe(struct usb_interface *intf,
/* driver requires remote-wakeup capability during autosuspend. */ /* driver requires remote-wakeup capability during autosuspend. */
intf->needs_remote_wakeup = 1; intf->needs_remote_wakeup = 1;
ret = lan78xx_phy_init(dev);
if (ret < 0)
goto out4;
ret = register_netdev(netdev); ret = register_netdev(netdev);
if (ret != 0) { if (ret != 0) {
netif_err(dev, probe, netdev, "couldn't register the device\n"); netif_err(dev, probe, netdev, "couldn't register the device\n");
goto out4; goto out5;
} }
usb_set_intfdata(intf, dev); usb_set_intfdata(intf, dev);
...@@ -3798,14 +3802,10 @@ static int lan78xx_probe(struct usb_interface *intf, ...@@ -3798,14 +3802,10 @@ static int lan78xx_probe(struct usb_interface *intf,
pm_runtime_set_autosuspend_delay(&udev->dev, pm_runtime_set_autosuspend_delay(&udev->dev,
DEFAULT_AUTOSUSPEND_DELAY); DEFAULT_AUTOSUSPEND_DELAY);
ret = lan78xx_phy_init(dev);
if (ret < 0)
goto out5;
return 0; return 0;
out5: out5:
unregister_netdev(netdev); phy_disconnect(netdev->phydev);
out4: out4:
usb_free_urb(dev->urb_intr); usb_free_urb(dev->urb_intr);
out3: out3:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment