perf: Fix task_struct reference leak
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Mon, 28 Mar 2011 11:13:56 +0000 (13:13 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 31 Mar 2011 11:02:56 +0000 (13:02 +0200)
sys_perf_event_open() had an imbalance in the number of task refs it
took causing memory leakage

Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: stable@kernel.org # .37+
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/perf_event.c

index 261690923ffb77d2060ac0a0dadeb4a716522917..27960f114efd73f9fb6ebec3d90952a643cd4284 100644 (file)
@@ -6531,6 +6531,11 @@ SYSCALL_DEFINE5(perf_event_open,
                goto err_alloc;
        }
 
+       if (task) {
+               put_task_struct(task);
+               task = NULL;
+       }
+
        /*
         * Look up the group leader (we will attach this event to it):
         */