Re: [PATCH] fix: net: mdio: of_phy_register_fixed_link: fix phy_device reference leak via discarded pointer
From: Andrew Lunn
Date: Fri Jun 26 2026 - 12:19:51 EST
On Fri, Jun 26, 2026 at 11:33:30PM +0800, WenTao Liang wrote:
> fixed_phy_register returns a struct phy_device pointer with a held
> reference on success. However, the register_phy label discards the
> pointer via PTR_ERR_OR_ZERO, and the phy_device's fwnode is not set, so
> of_phy_deregister_fixed_link cannot find the device via
> bus_find_device_by_fwnode to clean it up. This permanently leaks the
> phy_device and its device_node reference.
>
> Store the returned phy_device pointer and set dev->fwnode so the
> deregister path can properly locate and clean it up.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 24c30dbbcdda ("of/mdio: Add support function for Ethernet fixed-link property")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
Andrew
---
pw-bot: cr