]> www.infradead.org Git - nvme.git/commitdiff
of: resolver: Fix device node refcount leakage in of_resolve_phandles()
authorZijun Hu <quic_zijuhu@quicinc.com>
Mon, 24 Feb 2025 23:01:55 +0000 (17:01 -0600)
committerRob Herring (Arm) <robh@kernel.org>
Tue, 25 Feb 2025 13:19:13 +0000 (07:19 -0600)
In of_resolve_phandles(), refcount of device node @local_fixups will be
increased if the for_each_child_of_node() exits early, but nowhere to
decrease the refcount, so cause refcount leakage for the node.

Fix by using __free() on @local_fixups.

Fixes: da56d04c806a ("of/resolver: Switch to new local fixups format.")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250209-of_irq_fix-v2-9-93e3a2659aa7@quicinc.com
[robh: Use __free() instead]
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/resolver.c

index c871e35d4921760b73d2c94d56f953ff5e748285..2caad365a665c3cd268c66e014b1841b140e8c64 100644 (file)
@@ -249,8 +249,9 @@ static int adjust_local_phandle_references(const struct device_node *local_fixup
  */
 int of_resolve_phandles(struct device_node *overlay)
 {
-       struct device_node *child, *local_fixups, *refnode;
+       struct device_node *child, *refnode;
        struct device_node *overlay_fixups;
+       struct device_node __free(device_node) *local_fixups = NULL;
        struct property *prop;
        const char *refpath;
        phandle phandle, phandle_delta;