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

Commit 3e44017b authored by Lennert Buytenhek's avatar Lennert Buytenhek Committed by Jeff Garzik
Browse files

phylib: fix premature freeing of struct mii_bus



Commit 46abc021 ("phylib: give mdio
buses a device tree presence") added a call to device_unregister() in
a situation where the caller did not intend for the device to be
freed yet, but apart from just unregistering the device from the
system, device_unregister() does an additional put_device() that is
intended to free it.

The right function to use in this situation is device_del(), which
unregisters the device from the system like device_unregister() does,
but without dropping the reference count an additional time.

Bug report from Bryan Wu <cooloney@kernel.org>.

Signed-off-by: default avatarLennert Buytenhek <buytenh@marvell.com>
Tested-by: default avatarBryan Wu <cooloney@kernel.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 3b259e36
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ void mdiobus_unregister(struct mii_bus *bus)
	BUG_ON(bus->state != MDIOBUS_REGISTERED);
	bus->state = MDIOBUS_UNREGISTERED;

	device_unregister(&bus->dev);
	device_del(&bus->dev);
	for (i = 0; i < PHY_MAX_ADDR; i++) {
		if (bus->phy_map[i])
			device_unregister(&bus->phy_map[i]->dev);