* [PATCH 1/4] net: phy: call put_device on device_register() failure
[not found] <1386962557-8899-1-git-send-email-levex@linux.com>
@ 2013-12-13 19:22 ` Levente Kurusa
0 siblings, 0 replies; 2+ messages in thread
From: Levente Kurusa @ 2013-12-13 19:22 UTC (permalink / raw)
To: LKML
Cc: Levente Kurusa, Greg Kroah-Hartman, Grant Likely,
Michał Mirosław, netdev
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.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Levente Kurusa <levex@linux.com>
---
drivers/net/phy/mdio_bus.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 5617876..b071af7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -154,6 +154,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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/4] net: phy: call put_device on device_register() failure
[not found] ` <1386959996-7958-2-git-send-email-levex@linux.com>
@ 2013-12-14 17:25 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2013-12-14 17:25 UTC (permalink / raw)
To: Levente Kurusa; +Cc: LKML, Grant Likely, Michał Mirosław, netdev
On Fri, Dec 13, 2013 at 07:39:53PM +0100, Levente Kurusa wrote:
> 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.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Signed-off-by: Levente Kurusa <levex@linux.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-14 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1386962557-8899-1-git-send-email-levex@linux.com>
2013-12-13 19:22 ` [PATCH 1/4] net: phy: call put_device on device_register() failure Levente Kurusa
[not found] <1386959996-7958-1-git-send-email-levex@linux.com>
[not found] ` <1386959996-7958-2-git-send-email-levex@linux.com>
2013-12-14 17:25 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).