ARM: alpine: fix device_node refcount leak in alpine_cpu_pm_init()
PATCH 1/1 ARM: alpine: fix device_node refcount leak in alpine_cpu_pm_init()
of_find_compatible_node() returns the matching device_node with its refcount incremented; the caller must drop it with of_node_put(). alpine_cpu_pm_init() obtains the "al,alpine-cpu-resume" node, maps it with of_iomap() and never releases the reference. The function is __init and runs once, so this is a one-shot leak of a single refcount during boot, with no functional impact.
Drop the reference after of_iomap(), which does not retain it; np is not used afterwards.
Found by static analysis tool CodeQL.
---
Notes:
Compile-tested only (ARCH=arm multi_v7_defconfig, W=1). Not tested on hardware; I have no Alpine board.
The CodeQL query behind this report was synthesized with LLM assistance, and the fix and changelog were drafted with LLM assistance; I have reviewed them.
arch/arm/mach-alpine/alpine_cpu_pm.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-alpine/alpine_cpu_pm.c +1 -0
@@ -50,6 +50,7 @@ void __init alpine_cpu_pm_init(void) np =of_find_compatible_node (NULL ,NULL ,"al,alpine-cpu-resume" ); al_cpu_resume_regs =of_iomap (np,0 ); +of_node_put (np); wakeup_supported = !IS_ERR (al_sysfabric) && al_cpu_resume_regs;
base-commit: 165768bb70265b5c38cf0b73fafd75be235f8b14
prerequisite-patch-id: c5a3be8688fd8e88a00352acb1374e91fcb52a03
prerequisite-patch-id: 67693e2c08624df0841619cc085ce9200f4385fc
Signature · 1 line
2.43.0