net: phy: xgmiitorgmii: Fix refcount leak in xgmiitorgmii_probe
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 29 Dec 2022 06:29:25 +0000 (10:29 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 08:26:40 +0000 (09:26 +0100)
[ Upstream commit d039535850ee47079d59527e96be18d8e0daa84b ]

of_phy_find_device() return device node with refcount incremented.
Call put_device() to relese it when not needed anymore.

Fixes: ab4e6ee578e8 ("net: phy: xgmiitorgmii: Check phy_driver ready before accessing")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/xilinx_gmii2rgmii.c

index aef525467af06abd2d81214773fff490f38b21cd..55157c3197bd479ff3a92f5358d5cf190599e07e 100644 (file)
@@ -89,6 +89,7 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev)
 
        if (!priv->phy_dev->drv) {
                dev_info(dev, "Attached phy not ready\n");
+               put_device(&priv->phy_dev->mdio.dev);
                return -EPROBE_DEFER;
        }