Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b5bf3f3 authored by Andrew Lunn's avatar Andrew Lunn Committed by Greg Kroah-Hartman
Browse files

net: usb: lan78xx: Connect PHY before registering MAC



[ Upstream commit 38b4fe320119859c11b1dc06f6b4987a16344fa1 ]

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>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 07c62fc7
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -3799,10 +3799,14 @@ static int lan78xx_probe(struct usb_interface *intf,
	/* driver requires remote-wakeup capability during autosuspend. */
	intf->needs_remote_wakeup = 1;

	ret = lan78xx_phy_init(dev);
	if (ret < 0)
		goto out4;

	ret = register_netdev(netdev);
	if (ret != 0) {
		netif_err(dev, probe, netdev, "couldn't register the device\n");
		goto out4;
		goto out5;
	}

	usb_set_intfdata(intf, dev);
@@ -3815,14 +3819,10 @@ static int lan78xx_probe(struct usb_interface *intf,
	pm_runtime_set_autosuspend_delay(&udev->dev,
					 DEFAULT_AUTOSUSPEND_DELAY);

	ret = lan78xx_phy_init(dev);
	if (ret < 0)
		goto out5;

	return 0;

out5:
	unregister_netdev(netdev);
	phy_disconnect(netdev->phydev);
out4:
	usb_free_urb(dev->urb_intr);
out3: