瀏覽代碼

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: 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>
Johan Hovold 8 年之前
父節點
當前提交
3ae30f4ce6
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      drivers/of/of_mdio.c

+ 1 - 0
drivers/of/of_mdio.c

@@ -292,6 +292,7 @@ struct phy_device *of_phy_find_device(struct device_node *phy_np)
 		mdiodev = to_mdio_device(d);
 		mdiodev = to_mdio_device(d);
 		if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
 		if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
 			return to_phy_device(d);
 			return to_phy_device(d);
+		put_device(d);
 	}
 	}
 
 
 	return NULL;
 	return NULL;