net: ethernet: fs_enet: fix fixed-link phydev leaks
authorJohan Hovold <johan@kernel.org>
Mon, 28 Nov 2016 18:25:01 +0000 (19:25 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Nov 2016 04:17:02 +0000 (23:17 -0500)
Make sure to deregister and free any fixed-link PHY registered using
of_phy_register_fixed_link() on probe errors and on driver unbind.

Fixes: bb74d9a4a87b ("fs_enet: use the new fixed PHY helpers")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c

index dc120c148d9766fcf511f100396cb51f4b61a73b..4b86260584a056ead8a46f418d4a8cf52216aaad 100644 (file)
@@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
                err = clk_prepare_enable(clk);
                if (err) {
                        ret = err;
-                       goto out_free_fpi;
+                       goto out_deregister_fixed_link;
                }
                fpi->clk_per = clk;
        }
@@ -1061,6 +1061,9 @@ out_put:
        of_node_put(fpi->phy_node);
        if (fpi->clk_per)
                clk_disable_unprepare(fpi->clk_per);
+out_deregister_fixed_link:
+       if (of_phy_is_fixed_link(ofdev->dev.of_node))
+               of_phy_deregister_fixed_link(ofdev->dev.of_node);
 out_free_fpi:
        kfree(fpi);
        return ret;
@@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev)
        of_node_put(fep->fpi->phy_node);
        if (fep->fpi->clk_per)
                clk_disable_unprepare(fep->fpi->clk_per);
+       if (of_phy_is_fixed_link(ofdev->dev.of_node))
+               of_phy_deregister_fixed_link(ofdev->dev.of_node);
        free_netdev(ndev);
        return 0;
 }