[PATCH] ARM: mxs: fix missing of_node_put() in update_fec_mac_prop()

Wang Yufen wangyufen at huawei.com
Sun Dec 4 23:40:11 PST 2022


The device_node pointer returned by of_find_compatible_node() with
refcount incremented, when finish using it, the refcount need be
decreased.

Fixes: 5653acc24c13 ("ARM: mxs: store mac address read from OTP in device tree")
Signed-off-by: Wang Yufen <wangyufen at huawei.com>
---
 arch/arm/mach-mxs/mach-mxs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 1c57ac4..5e11580 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -180,14 +180,14 @@ static void __init update_fec_mac_prop(enum mac_oui oui)
 
 		newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
 		if (!newmac)
-			return;
+			goto out;
 		newmac->value = newmac + 1;
 		newmac->length = 6;
 
 		newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
 		if (!newmac->name) {
 			kfree(newmac);
-			return;
+			goto out;
 		}
 
 		/*
@@ -229,6 +229,10 @@ static void __init update_fec_mac_prop(enum mac_oui oui)
 
 		of_update_property(np, newmac);
 	}
+
+out:
+	of_node_put(np);
+	return;
 }
 
 static inline void enable_clk_enet_out(void)
-- 
1.8.3.1




More information about the linux-arm-kernel mailing list