Make sure to drop the reference taken by of_phy_find_device() when
registering and deregistering the fixed-link PHY-device.
Fixes: 39b0c705195e ("net: dsa: Allow configuration of CPU & DSA port
speeds/duplex")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
                genphy_read_status(phydev);
                if (ds->ops->adjust_link)
                        ds->ops->adjust_link(ds, port, phydev);
+
+               put_device(&phydev->mdio.dev);
        }
 
        return 0;
        if (of_phy_is_fixed_link(port_dn)) {
                phydev = of_phy_find_device(port_dn);
                if (phydev) {
-                       phy_device_free(phydev);
                        fixed_phy_unregister(phydev);
+                       put_device(&phydev->mdio.dev);
+                       phy_device_free(phydev);
                }
        }
 }