Skip to content

Commit 06b74c6

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "A handful of CPU hotplug related fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/core: Plug potential memory leak in CPU_UP_PREPARE perf/core: Remove the bogus and dangerous CPU_DOWN_FAILED hotplug state perf/core: Remove bogus UP_CANCELED hotplug state perf/x86/amd/uncore: Plug reference leak
2 parents e6a1c1e + 059fcd8 commit 06b74c6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

arch/x86/kernel/cpu/perf_event_amd_uncore.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ static int amd_uncore_cpu_up_prepare(unsigned int cpu)
323323
return 0;
324324

325325
fail:
326+
if (amd_uncore_nb)
327+
*per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
326328
kfree(uncore_nb);
327329
return -ENOMEM;
328330
}

kernel/events/core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9206,7 +9206,7 @@ static void perf_event_init_cpu(int cpu)
92069206
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
92079207

92089208
mutex_lock(&swhash->hlist_mutex);
9209-
if (swhash->hlist_refcount > 0) {
9209+
if (swhash->hlist_refcount > 0 && !swevent_hlist_deref(swhash)) {
92109210
struct swevent_hlist *hlist;
92119211

92129212
hlist = kzalloc_node(sizeof(*hlist), GFP_KERNEL, cpu_to_node(cpu));
@@ -9282,11 +9282,9 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
92829282
switch (action & ~CPU_TASKS_FROZEN) {
92839283

92849284
case CPU_UP_PREPARE:
9285-
case CPU_DOWN_FAILED:
92869285
perf_event_init_cpu(cpu);
92879286
break;
92889287

9289-
case CPU_UP_CANCELED:
92909288
case CPU_DOWN_PREPARE:
92919289
perf_event_exit_cpu(cpu);
92929290
break;

0 commit comments

Comments
 (0)