diff options
author | Roger Quadros <rogerq@ti.com> | 2014-07-10 11:55:02 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-11 18:23:49 -0700 |
commit | e73b49f1c4e75c44d62585cc3e5b9c7894b61c32 (patch) | |
tree | 95b3336a3ec82f1b434b38747179e69b54cccbd6 /drivers | |
parent | bf5baf954a8249ad565862faa98accb19f3ab957 (diff) | |
download | linux-e73b49f1c4e75c44d62585cc3e5b9c7894b61c32.tar.gz linux-e73b49f1c4e75c44d62585cc3e5b9c7894b61c32.tar.bz2 linux-e73b49f1c4e75c44d62585cc3e5b9c7894b61c32.zip |
phy: core: Fix error path in phy_create()
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.
Cc: 3.13+ <stable@vger.kernel.org> # 3.13+
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/phy/phy-core.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index c64a2f3b2d62..49c446530101 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -614,8 +614,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); @@ -799,7 +800,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); } |