Skip to content

Commit e76ca27

Browse files
Tyrel Datwylermpe
authored andcommitted
powerpc/sysfs: Fix reference leak of cpu device_nodes present at boot
For CPUs present at boot each logical CPU acquires a reference to the associated device node of the core. This happens in register_cpu() which is called by topology_init(). The result of this is that we end up with a reference held by each thread of the core. However, these references are never freed if the CPU core is DLPAR removed. This patch fixes the reference leaks by acquiring and releasing the references in the CPU hotplug callbacks un/register_cpu_online(). With this patch symmetric reference counting is observed with both CPUs present at boot, and those DLPAR added after boot. Fixes: f86e471 ("driver/core: cpu: initialize of_node in cpu's device struture") Cc: [email protected] # v3.12+ Signed-off-by: Tyrel Datwyler <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 68baf69 commit e76ca27

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/powerpc/kernel/sysfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,10 @@ static int register_cpu_online(unsigned int cpu)
710710
struct device_attribute *attrs, *pmc_attrs;
711711
int i, nattrs;
712712

713+
/* For cpus present at boot a reference was already grabbed in register_cpu() */
714+
if (!s->of_node)
715+
s->of_node = of_get_cpu_node(cpu, NULL);
716+
713717
#ifdef CONFIG_PPC64
714718
if (cpu_has_feature(CPU_FTR_SMT))
715719
device_create_file(s, &dev_attr_smt_snooze_delay);
@@ -864,6 +868,8 @@ static int unregister_cpu_online(unsigned int cpu)
864868
}
865869
#endif
866870
cacheinfo_cpu_offline(cpu);
871+
of_node_put(s->of_node);
872+
s->of_node = NULL;
867873
#endif /* CONFIG_HOTPLUG_CPU */
868874
return 0;
869875
}

0 commit comments

Comments
 (0)