1
0
Fork 0

of_mdio: fix device reference leak in of_phy_find_device

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: 6ed742363b ("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>
hifive-unleashed-5.1
Johan Hovold 2016-11-16 15:20:37 +01:00 committed by David S. Miller
parent 48c1699d53
commit 3ae30f4ce6
1 changed files with 1 additions and 0 deletions

View 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;