Re: [PATCH] net: dsa: microchip: fix mdio parent bus reference leak

From: Oleksij Rempel

Date: Fri Nov 21 2025 - 00:41:41 EST


Hi,

On Fri, Nov 21, 2025 at 12:20:00PM +0800, Ma Ke wrote:
> In ksz_mdio_register(), when of_mdio_find_bus() is called to get the
> parent MDIO bus, it increments the reference count of the underlying
> device. However, the reference are not released in error paths or
> during switch teardown, causing a reference leak.
>
> Add put_device() in the error path of ksz_mdio_register() and
> ksz_teardown() to release the parent bus.
>
> Found by code review.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 9afaf0eec2ab ("net: dsa: microchip: Refactor MDIO handling for side MDIO access")
> Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>

Reviewed-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

Thank you!

Best Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |