Commit 191759e5 authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

perf: Make RB allocation branch self sufficient



Ensure @rb usage doesn't extend out of the branch block.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://lore.kernel.org/r/20250812104019.605285302@infradead.org
parent 2aee3768
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -7116,8 +7116,6 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
				 * multiple times.
				 */
				ret = 0;
				/* We need the rb to map pages. */
				rb = event->rb;
				perf_mmap_account(vma, user_extra, extra);
				atomic_inc(&event->mmap_count);
				goto unlock;
@@ -7136,8 +7134,6 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
			goto unlock;
		}

		WARN_ON(!rb && event->rb);

		if (vma->vm_flags & VM_WRITE)
			flags |= RING_BUFFER_WRITABLE;

@@ -7190,7 +7186,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
	 * full cleanup in this case and therefore does not invoke
	 * vmops::close().
	 */
	ret = map_range(rb, vma);
	ret = map_range(event->rb, vma);
	if (ret)
		perf_mmap_close(vma);