Commit 54473e0e authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

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: 0983593f ("perf/core: Lift event->mmap_mutex in perf_mmap()")
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: stable@vger.kernel.org
parent 7e161a99
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -7115,6 +7115,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
		perf_event_update_time(event);
		perf_event_init_userpage(event);
		perf_event_update_userpage(event);
		ret = 0;
	} else {
		ret = rb_alloc_aux(rb, event, vma->vm_pgoff, nr_pages,
				   event->attr.aux_watermark, flags);
@@ -7122,8 +7123,6 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
			rb->aux_mmap_locked = extra;
	}

	ret = 0;

unlock:
	if (!ret) {
		atomic_long_add(user_extra, &user->locked_vm);