summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTyrel Datwyler <tyreld@linux.vnet.ibm.com>2017-04-17 20:24:39 -0400
committerBen Hutchings <ben@decadent.org.uk>2017-08-26 02:14:38 +0100
commitf0be7fe7f619cf915320713371f47a7931245563 (patch)
treedb80f4dfe354218fde7b92ccaf24b37f41766389 /arch
parente733d4629ce75458b02badef7afded3a63713066 (diff)
downloadlinux-stable-f0be7fe7f619cf915320713371f47a7931245563.tar.gz
linux-stable-f0be7fe7f619cf915320713371f47a7931245563.tar.bz2
linux-stable-f0be7fe7f619cf915320713371f47a7931245563.zip
powerpc/sysfs: Fix reference leak of cpu device_nodes present at boot
commit e76ca27790a514590af782f83f6eae49e0ccf8c9 upstream. 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: f86e4718f24b ("driver/core: cpu: initialize of_node in cpu's device struture") Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/sysfs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 67fd2fd2620a..52e12019e101 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -672,6 +672,10 @@ static void register_cpu_online(unsigned int cpu)
struct device_attribute *attrs, *pmc_attrs;
int i, nattrs;
+ /* For cpus present at boot a reference was already grabbed in register_cpu() */
+ if (!s->of_node)
+ s->of_node = of_get_cpu_node(cpu, NULL);
+
#ifdef CONFIG_PPC64
if (cpu_has_feature(CPU_FTR_SMT))
device_create_file(s, &dev_attr_smt_snooze_delay);
@@ -825,6 +829,8 @@ static void unregister_cpu_online(unsigned int cpu)
}
#endif
cacheinfo_cpu_offline(cpu);
+ of_node_put(s->of_node);
+ s->of_node = NULL;
}
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE