Re: [PATCH] mfd: altera-sysmgr: Fix device reference leak in altr_sysmgr_regmap_lookup_by_phandle

From: Lee Jones

Date: Thu Nov 06 2025 - 11:51:00 EST


On Tue, 28 Oct 2025, Miaoqian Lin wrote:

> driver_find_device_by_of_node() calls driver_find_device(), which calls
> get_device(). get_device() increments the device's reference count,
> so driver_find_device_by_of_node() returns a device
> with its reference count incremented.
> We need to release this reference after usage to avoid a reference leak.
>
> Add put_device(dev) after dev_get_drvdata() to fix the reference leak.
>
> Found via static analysis.
>
> Fixes: f36e789a1f8d ("mfd: altera-sysmgr: Add SOCFPGA System Manager")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx>

Looks like Johan beat you to it.

--
Lee Jones [李琼斯]