This is a note to let you know that I've just added the patch titled net: ethernet: ucc_geth: fix fixed-link phydev leaks to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: net-ethernet-ucc_geth-fix-fixed-link-phydev-leaks.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 0807c4ceb8d171a116edc33e34166416876cae5d Mon Sep 17 00:00:00 2001 From: Johan Hovold <johan@xxxxxxxxxx> Date: Mon, 28 Nov 2016 19:25:03 +0100 Subject: net: ethernet: ucc_geth: fix fixed-link phydev leaks From: Johan Hovold <johan@xxxxxxxxxx> commit 0807c4ceb8d171a116edc33e34166416876cae5d upstream. 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: 87009814cdbb ("ucc_geth: use the new fixed PHY helpers") Signed-off-by: Johan Hovold <johan@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/net/ethernet/freescale/ucc_geth.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3870,9 +3870,8 @@ static int ucc_geth_probe(struct platfor dev = alloc_etherdev(sizeof(*ugeth)); if (dev == NULL) { - of_node_put(ug_info->tbi_node); - of_node_put(ug_info->phy_node); - return -ENOMEM; + err = -ENOMEM; + goto err_deregister_fixed_link; } ugeth = netdev_priv(dev); @@ -3909,10 +3908,7 @@ static int ucc_geth_probe(struct platfor if (netif_msg_probe(ugeth)) pr_err("%s: Cannot register net device, aborting\n", dev->name); - free_netdev(dev); - of_node_put(ug_info->tbi_node); - of_node_put(ug_info->phy_node); - return err; + goto err_free_netdev; } mac_addr = of_get_mac_address(np); @@ -3925,16 +3921,29 @@ static int ucc_geth_probe(struct platfor ugeth->node = np; return 0; + +err_free_netdev: + free_netdev(dev); +err_deregister_fixed_link: + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + of_node_put(ug_info->tbi_node); + of_node_put(ug_info->phy_node); + + return err; } static int ucc_geth_remove(struct platform_device* ofdev) { struct net_device *dev = platform_get_drvdata(ofdev); struct ucc_geth_private *ugeth = netdev_priv(dev); + struct device_node *np = ofdev->dev.of_node; unregister_netdev(dev); free_netdev(dev); ucc_geth_memclean(ugeth); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); of_node_put(ugeth->ug_info->tbi_node); of_node_put(ugeth->ug_info->phy_node); Patches currently in stable-queue which might be from johan@xxxxxxxxxx are queue-4.4/of_mdio-fix-node-leak-in-of_phy_register_fixed_link-error-path.patch queue-4.4/net-ethernet-gianfar-fix-fixed-link-phydev-leaks.patch queue-4.4/net-ethernet-ucc_geth-fix-fixed-link-phydev-leaks.patch queue-4.4/phy-fix-device-reference-leaks.patch queue-4.4/net-dsa-slave-fix-of-node-leak-and-phy-priority.patch queue-4.4/net-ethernet-marvell-mvneta-fix-fixed-link-phydev-leaks.patch queue-4.4/net-ethernet-fs_enet-fix-fixed-link-phydev-leaks.patch