[PATCH] x86/devicetree: Fix refcount leak in dtb_lapic_setup

From: cgel . zte
Date: Sat Apr 02 2022 - 04:47:20 EST


From: Lv Ruyi <lv.ruyi@xxxxxxxxxx>

If dn is true that meas the of_find_compatible_node function
successfully returns a node pointer with refcount incremented,
use of_node_put() on it when done.

Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Lv Ruyi <lv.ruyi@xxxxxxxxxx>
---
arch/x86/kernel/devicetree.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 5cd51f25f446..6498825cf48d 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -156,6 +156,7 @@ static void __init dtb_lapic_setup(void)
dn = of_find_compatible_node(NULL, NULL, "intel,ce4100-lapic");
if (dn) {
ret = of_address_to_resource(dn, 0, &r);
+ of_node_put(dn);
if (WARN_ON(ret))
return;
lapic_addr = r.start;
--
2.25.1