[PATCH] of: Fix phandle_node reference leak in of_map_id()

From: Wentao Liang

Date: Thu Sep 17 2026 - 08:49:13 EST


of_find_node_by_phandle() returns a node with an elevated reference
count. When the caller passes target == NULL it only wants the
translated ID, so that reference is never handed over and must be
dropped before returning success.

Fixes: 987068fcbdb7 ("of/irq: Break out msi-map lookup (again)")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/of/base.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a650c91897cc..0f548d103037 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2201,6 +2201,8 @@ int of_map_id(const struct device_node *np, u32 id,

if (*target != phandle_node)
continue;
+ } else {
+ of_node_put(phandle_node);
}

if (id_out)
--
2.34.1