Re: [PATCH] fix: net: phy: phy_sfp_probe: fix kref leak when phy_setup_sfp_port fails after sfp_bus_add_upstream
From: Andrew Lunn
Date: Fri Jun 26 2026 - 12:14:21 EST
On Fri, Jun 26, 2026 at 11:34:43PM +0800, WenTao Liang wrote:
> sfp_bus_add_upstream unconditionally acquires a kref on the SFP bus. When
> this call succeeds but the subsequent phy_setup_sfp_port fails, the error
> path returns without releasing the upstream reference. Since probe fails,
> the device's remove function (which would normally clean this up) will
> never be called, permanently leaking the kref.
>
> Call sfp_bus_del_upstream on the error path after a successful
> sfp_bus_add_upstream to properly release the upstream reference.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 298e54fa810e ("net: phy: add core phylib sfp support")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
Andrew
---
pw-bot: cr