Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/net/phy/mdio_bus.c: call put_device on device_register() failure

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 <levex@linux.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: David Daney <david.daney@cavium.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Levente Kurusa and committed by
Linus Torvalds
0c692d07 54f5968d

+1
+1
drivers/net/phy/mdio_bus.c
··· 150 150 err = device_register(&bus->dev); 151 151 if (err) { 152 152 pr_err("mii_bus %s failed to register\n", bus->id); 153 + put_device(&bus->dev); 153 154 return -EINVAL; 154 155 } 155 156