mfd: altera-sysmgr: Fix device reference leak in altr_sysmgr_regmap_lookup_by_phandle
Subsystems (2)
PATCH 1/1 mfd: altera-sysmgr: Fix device reference leak in altr_sysmgr_regmap_lookup_by_phandle
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.
--- drivers/mfd/altera-sysmgr.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/altera-sysmgr.c +1 -0
@@ -116,6 +116,7 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np,return ERR_PTR (-EPROBE_DEFER ); sysmgr =dev_get_drvdata (dev); +put_device (dev);return sysmgr->regmap; }
Signature · 1 line
2.39.5 (Apple Git-154)
Lee Jones
maintainerQuoted 6 lines · Miaoqian Lin
driver_find_device_by_of_node()callsdriver_find_device(), which callsget_device().get_device()increments the device's reference count, sodriver_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.
Quoted 7 lines
Add
put_device(dev)afterdev_get_drvdata()to fix the reference leak.Found via static analysis.
Fixes f36e789a1f8d ("mfd: altera-sysmgr: Add SOCFPGA System Manager")Signed-off-by Miaoqian Lin <[email protected]>
Looks like Johan beat you to it.
Signature · 1 line
Lee Jones [李琼斯]