]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
of_mdio: fix device reference leak in of_phy_find_device
authorJohan Hovold <johan@kernel.org>
Wed, 16 Nov 2016 14:20:37 +0000 (15:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Nov 2016 17:05:04 +0000 (12:05 -0500)
Make sure to drop the reference taken by bus_find_device() before
returning NULL from of_phy_find_device() when the found device is not a
PHY.

Fixes: 6ed742363b9c ("of: of_mdio: Ensure mdio device is a PHY")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/of/of_mdio.c

index 8f4648383fb265d68267698121e261f80a541474..5a3145a025470dc4c86f8d191a139a8acb85394f 100644 (file)
@@ -292,6 +292,7 @@ struct phy_device *of_phy_find_device(struct device_node *phy_np)
                mdiodev = to_mdio_device(d);
                if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
                        return to_phy_device(d);
+               put_device(d);
        }
 
        return NULL;