Driver should call phy_remove_lookup if it create lookup
for non-dt case, otherwise mem leak issue will happen when
removing driver.

Fixes: 61211b1b ("phy: twl4030: use the new lookup method")
Signed-off-by: Shawn Lin <[email protected]>
---

 drivers/phy/phy-twl4030-usb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 4a3fc6e..d3f905e 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -748,6 +748,8 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 static int twl4030_usb_remove(struct platform_device *pdev)
 {
        struct twl4030_usb *twl = platform_get_drvdata(pdev);
+       struct twl4030_usb_data *pdata = dev_get_platdata(&pdev->dev);
+       struct phy *phy;
        int val;
 
        pm_runtime_get_sync(twl->dev);
@@ -771,6 +773,14 @@ static int twl4030_usb_remove(struct platform_device *pdev)
        /* disable complete OTG block */
        twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
 
+       if (pdata) {
+               phy = phy_get(twl->dev, "usb");
+               if (!IS_ERR(phy)) {
+                       phy_remove_lookup(phy, "usb", "musb-hdrc.0");
+                       phy_put(phy);
+               }
+       }
+
        if (cable_present(twl->linkstat))
                pm_runtime_put_noidle(twl->dev);
        pm_runtime_mark_last_busy(twl->dev);
-- 
2.3.7


Reply via email to