Re: [PATCH net v2 2/3] dpaa2-eth: Fix device reference count leak in MAC endpoint handling

From: Simon Horman
Date: Fri Jul 18 2025 - 10:42:47 EST


On Thu, Jul 17, 2025 at 10:23:08AM +0800, Ma Ke wrote:
> The fsl_mc_get_endpoint() function uses device_find_child() for
> localization, which implicitly calls get_device() to increment the
> device's reference count before returning the pointer. However, the
> caller dpaa2_eth_connect_mac() fails to properly release this
> reference in multiple scenarios. We should call put_device() to
> decrement reference count properly.
>
> As comment of device_find_child() says, 'NOTE: you will need to drop
> the reference with put_device() after use'.
>
> Found by code review.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
> Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>