Commit f0ddd6e7 authored by Roger Quadros's avatar Roger Quadros Committed by Kamal Mostafa

phy: core: Fix error path in phy_create()

commit e73b49f1 upstream.

Prevent resources from being freed twice in case device_add() call
fails within phy_create(). Also use ida_simple_remove() instead of
ida_remove() as we had used ida_simple_get() to allocate the ida.
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent f2aa1354
......@@ -477,8 +477,9 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
return phy;
put_dev:
put_device(&phy->dev);
ida_remove(&phy_ida, phy->id);
put_device(&phy->dev); /* calls phy_release() which frees resources */
return ERR_PTR(ret);
free_phy:
kfree(phy);
return ERR_PTR(ret);
......@@ -662,7 +663,7 @@ static void phy_release(struct device *dev)
phy = to_phy(dev);
dev_vdbg(dev, "releasing '%s'\n", dev_name(dev));
ida_remove(&phy_ida, phy->id);
ida_simple_remove(&phy_ida, phy->id);
kfree(phy);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment