]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: ethernet: ti: cpsw: fix device and of_node leaks
authorJohan Hovold <johan@kernel.org>
Thu, 3 Nov 2016 17:40:20 +0000 (18:40 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Nov 2016 18:17:30 +0000 (13:17 -0500)
Make sure to drop the references taken by of_get_child_by_name() and
bus_find_device() before returning from cpsw_phy_sel().

Note that holding a reference to the cpsw-phy-sel device does not
prevent the devres-managed private data from going away.

Fixes: 91b2b225efec ("drivers: net: cpsw-phy-sel: Add new driver...")
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw-phy-sel.c

index 054a8dd23dae0df966fc508064734946ed8f6d2b..ba1e45ff6aaec2ed3dcce6a3a4fc089c3be711d4 100644 (file)
@@ -176,9 +176,12 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
        }
 
        dev = bus_find_device(&platform_bus_type, NULL, node, match);
+       of_node_put(node);
        priv = dev_get_drvdata(dev);
 
        priv->cpsw_phy_sel(priv, phy_mode, slave);
+
+       put_device(dev);
 }
 EXPORT_SYMBOL_GPL(cpsw_phy_sel);