Commit e7d0bc047548d76feee6b23f7d3d9da927189a50
Committed by
Ingo Molnar
1 parent
74c3337c2f
Exists in
master
and in
4 other branches
perf: Fix task refcount bugs
Currently it looks like find_lively_task_by_vpid() takes a task ref and relies on find_get_context() to drop it. The problem is that perf_event_create_kernel_counter() shouldn't be dropping task refs. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Matt Helsley <matthltc@us.ibm.com> LKML-Reference: <20101014203625.278436085@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
kernel/perf_event.c
... | ... | @@ -2190,11 +2190,9 @@ |
2190 | 2190 | } |
2191 | 2191 | } |
2192 | 2192 | |
2193 | - put_task_struct(task); | |
2194 | 2193 | return ctx; |
2195 | 2194 | |
2196 | 2195 | errout: |
2197 | - put_task_struct(task); | |
2198 | 2196 | return ERR_PTR(err); |
2199 | 2197 | } |
2200 | 2198 | |
... | ... | @@ -5602,7 +5600,7 @@ |
5602 | 5600 | ctx = find_get_context(pmu, task, cpu); |
5603 | 5601 | if (IS_ERR(ctx)) { |
5604 | 5602 | err = PTR_ERR(ctx); |
5605 | - goto err_group_fd; | |
5603 | + goto err_task; | |
5606 | 5604 | } |
5607 | 5605 | |
5608 | 5606 | /* |
... | ... | @@ -5698,6 +5696,9 @@ |
5698 | 5696 | |
5699 | 5697 | err_context: |
5700 | 5698 | put_ctx(ctx); |
5699 | +err_task: | |
5700 | + if (task) | |
5701 | + put_task_struct(task); | |
5701 | 5702 | err_group_fd: |
5702 | 5703 | fput_light(group_file, fput_needed); |
5703 | 5704 | free_event(event); |