mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
net: phy: fix memory leak in device-create error path
A recent commit introduced a late error path in phy_device_create()
which fails to release the device name allocated by dev_set_name().
Fixes: 13d0ab6750
("net: phy: check return code when requesting PHY driver module")
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1c3b63f155
commit
d02cbc4613
1 changed files with 4 additions and 4 deletions
|
@ -615,7 +615,9 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
|
||||||
if (c45_ids)
|
if (c45_ids)
|
||||||
dev->c45_ids = *c45_ids;
|
dev->c45_ids = *c45_ids;
|
||||||
dev->irq = bus->irq[addr];
|
dev->irq = bus->irq[addr];
|
||||||
|
|
||||||
dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr);
|
dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr);
|
||||||
|
device_initialize(&mdiodev->dev);
|
||||||
|
|
||||||
dev->state = PHY_DOWN;
|
dev->state = PHY_DOWN;
|
||||||
|
|
||||||
|
@ -649,10 +651,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
|
||||||
ret = phy_request_driver_module(dev, phy_id);
|
ret = phy_request_driver_module(dev, phy_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if (ret) {
|
||||||
device_initialize(&mdiodev->dev);
|
put_device(&mdiodev->dev);
|
||||||
} else {
|
|
||||||
kfree(dev);
|
|
||||||
dev = ERR_PTR(ret);
|
dev = ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue