[PATCH] bus: fsl-mc: fix device reference leak in fsl_mc_device_lookup()

Ioana Ciornei ioana.ciornei at nxp.com
Sat Oct 25 00:07:43 AEDT 2025


On Thu, Oct 23, 2025 at 11:05:58PM +0800, Wentao Liang wrote:
> The device_find_child() function calls the get_device() and returns a
> device reference that must be properly released when no longer needed.

The release should be done when no longer needed, not even before
returning the device to the caller.

> The fsl_mc_device_lookup() directly returns without releasing the
> reference via put_device().
> 
> Add the missing put_device() call to prevent reference leaks.
> 

No, the call to put_device should not be done from fsl_mc_device_lookup()
but instead from its callers when indeed the device is no longer in use.
For example, fsl_mc_obj_device_add() does call put_device().

Ioana


More information about the Linuxppc-dev mailing list