Commit c1b1731d authored by Sachin Kamat's avatar Sachin Kamat Committed by Greg Kroah-Hartman

drivers: phy: Fix memory leak

'phy' was not being freed upon error in one of the cases.
Adjust the 'goto's to fix this.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1caab68b
...@@ -453,7 +453,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, ...@@ -453,7 +453,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
if (id < 0) { if (id < 0) {
dev_err(dev, "unable to get id\n"); dev_err(dev, "unable to get id\n");
ret = id; ret = id;
goto err0; goto err1;
} }
device_initialize(&phy->dev); device_initialize(&phy->dev);
...@@ -468,11 +468,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, ...@@ -468,11 +468,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id); ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
if (ret) if (ret)
goto err1; goto err2;
ret = device_add(&phy->dev); ret = device_add(&phy->dev);
if (ret) if (ret)
goto err1; goto err2;
if (pm_runtime_enabled(dev)) { if (pm_runtime_enabled(dev)) {
pm_runtime_enable(&phy->dev); pm_runtime_enable(&phy->dev);
...@@ -481,11 +481,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, ...@@ -481,11 +481,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
return phy; return phy;
err1: err2:
ida_remove(&phy_ida, phy->id); ida_remove(&phy_ida, phy->id);
put_device(&phy->dev); put_device(&phy->dev);
err1:
kfree(phy); kfree(phy);
err0: err0:
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
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