Skip to content

Commit 54473e0

Browse files
committed
perf/core: Preserve AUX buffer allocation failure result
A recent overhaul sets the return value to 0 unconditionally after the allocations, which causes reference count leaks and corrupts the user->vm accounting. Preserve the AUX buffer allocation failure return value, so that the subsequent code works correctly. Fixes: 0983593 ("perf/core: Lift event->mmap_mutex in perf_mmap()") Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Cc: [email protected]
1 parent 7e161a9 commit 54473e0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/events/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7115,15 +7115,14 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
71157115
perf_event_update_time(event);
71167116
perf_event_init_userpage(event);
71177117
perf_event_update_userpage(event);
7118+
ret = 0;
71187119
} else {
71197120
ret = rb_alloc_aux(rb, event, vma->vm_pgoff, nr_pages,
71207121
event->attr.aux_watermark, flags);
71217122
if (!ret)
71227123
rb->aux_mmap_locked = extra;
71237124
}
71247125

7125-
ret = 0;
7126-
71277126
unlock:
71287127
if (!ret) {
71297128
atomic_long_add(user_extra, &user->locked_vm);

0 commit comments

Comments
 (0)