mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
ARM: imx: fix device_node refcount leaks in imx7_src_init()
imx7_src_init() obtains two device_node references via
of_find_compatible_node() - one for "fsl,imx7d-src" and one for
"fsl,imx7d-gpc" - reusing the same np variable, but never calls
of_node_put() on either. On every i.MX7D boot up to two device_node
refcounts are leaked:
- The "fsl,imx7d-src" node is leaked both when of_iomap() fails (the
early return after the mapping) and when it succeeds, because np is
then overwritten by the second of_find_compatible_node() call
without releasing the prior reference.
- The "fsl,imx7d-gpc" node is leaked on every path leaving the
function after it is acquired.
Release each reference immediately after of_iomap() consumes the node.
of_iomap() maps the node's registers but does not retain a reference to
the device_node, so it is safe to put the node once mapped; this also
drops the first reference before np is reused for the second lookup.
Found by static analysis tool CodeQL.
Fixes: e34645f458 ("ARM: imx: add smp support for imx7d")
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
This commit is contained in:
parent
936407c356
commit
3de939b2ac
|
|
@ -196,6 +196,7 @@ void __init imx7_src_init(void)
|
|||
return;
|
||||
|
||||
src_base = of_iomap(np, 0);
|
||||
of_node_put(np);
|
||||
if (!src_base)
|
||||
return;
|
||||
|
||||
|
|
@ -204,6 +205,7 @@ void __init imx7_src_init(void)
|
|||
return;
|
||||
|
||||
gpc_base = of_iomap(np, 0);
|
||||
of_node_put(np);
|
||||
if (!gpc_base)
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user