drivers/net/phy/mdio_bus.c: call put_device on device_register() failure
authorLevente Kurusa <[email protected]>
Thu, 30 Jan 2014 23:45:46 +0000 (15:45 -0800)
committerLinus Torvalds <[email protected]>
Fri, 31 Jan 2014 00:56:54 +0000 (16:56 -0800)
It is required to call put_device() if device_register() fails, so that
we give up the last reference to the device.  Calling put_device allows
for mdiobus_release to be executed, kfreeing the bus.

Signed-off-by: Levente Kurusa <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Grant Likely <[email protected]>
Cc: David Daney <[email protected]>
Cc: David S. Miller <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/net/phy/mdio_bus.c

index 930694d3a13f7e7568fab6997ccdcd0ecabbb063..71e49000fbf33fc50d08e3c6979014c89fdb4478 100644 (file)
@@ -150,6 +150,7 @@ int mdiobus_register(struct mii_bus *bus)
        err = device_register(&bus->dev);
        if (err) {
                pr_err("mii_bus %s failed to register\n", bus->id);
+               put_device(&bus->dev);
                return -EINVAL;
        }