Skip to contentSkip to conversation

arch: x86: kernel: Add missing of_node_put() in x86_init.c

PATCH In review Liang He 2 participants 2 messages Jun 15, 2022 – Oct 17, 2022 x86

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 arch: x86: kernel: Add missing of_node_put() in x86_init.c

In x86_wallclock_init(), we need to use of_node_put() for the of_find_matching_node() which returns a node pointer with refcount incremented.

---
 arch/x86/kernel/x86_init.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/x86_init.c +1 -0
index e84ee5cdbd8c..81c071080efe 100644
@@ -50,6 +50,7 @@ static __init void x86_wallclock_init(void)
 	struct device_node *node = of_find_matching_node(NULL, of_cmos_match);
 
 	if (node && !of_device_is_available(node)) {
+		of_node_put(node);
 		x86_platform.get_wallclock = get_rtc_noop;
 		x86_platform.set_wallclock = set_rtc_noop;
 	}
Signature · 1 line
2.25.1
#1 lore raw

Liang,

On Wed, Jun 15 2022 at 20:57, Liang He wrote:

please check https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
for instructions vs. subject prefixes and changelogs.

Quoted 14 lines

In x86_wallclock_init(), we need to use of_node_put() for the of_find_matching_node() which returns a node pointer with refcount incremented.

---
 arch/x86/kernel/x86_init.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/x86_init.c +0 -0
index e84ee5cdbd8c..81c071080efe 100644

arch/x86/kernel/x86_init.c static __init void x86_wallclock_init(void) · line 56

Quoted 7 lines
arch/x86/kernel/x86_init.c +1 -0
@@ -50,6 +50,7 @@ static __init void x86_wallclock_init(void)
 	struct device_node *node = of_find_matching_node(NULL, of_cmos_match);
 
 	if (node && !of_device_is_available(node)) {
+		of_node_put(node);
 		x86_platform.get_wallclock = get_rtc_noop;
 		x86_platform.set_wallclock = set_rtc_noop;
 	}

That still leaks the node in the case when the device is available, no?

Thanks,

tglx