[PATCH 2/5] perf, x86: Fix silly bug in data store buffer allocation

Peter Zijlstra
2010-03-05T15:43:22Z

[-- Attachment #1: perf-fixup-intel-ds.patch --]
[-- Type: text/plain, Size: 762 bytes --]

Fix up the ds allocation error path, where we could free @buffer
before we used it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
arch/x86/kernel/cpu/perf_event_intel_ds.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6/arch/x86/kernel/cpu/perf_event_intel_ds.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ linux-2.6/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -127,10 +127,8 @@ static int reserve_ds_buffers(void)

err = -ENOMEM;
ds = kzalloc(sizeof(*ds), GFP_KERNEL);
- if (unlikely(!ds)) {
- kfree(buffer);
+ if (unlikely(!ds))
break;
- }
per_cpu(cpu_hw_events, cpu).ds = ds;

if (x86_pmu.bts) {

--