提交 c1b1731d 编写于 作者: S Sachin Kamat 提交者: 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: NSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: NKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1caab68b
......@@ -453,7 +453,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
if (id < 0) {
dev_err(dev, "unable to get id\n");
ret = id;
goto err0;
goto err1;
}
device_initialize(&phy->dev);
......@@ -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);
if (ret)
goto err1;
goto err2;
ret = device_add(&phy->dev);
if (ret)
goto err1;
goto err2;
if (pm_runtime_enabled(dev)) {
pm_runtime_enable(&phy->dev);
......@@ -481,11 +481,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
return phy;
err1:
err2:
ida_remove(&phy_ida, phy->id);
put_device(&phy->dev);
err1:
kfree(phy);
err0:
return ERR_PTR(ret);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册