]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf: Make RB allocation branch self sufficient
authorPeter Zijlstra <peterz@infradead.org>
Tue, 12 Aug 2025 10:39:09 +0000 (12:39 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 15 Aug 2025 11:13:01 +0000 (13:13 +0200)
Ensure @rb usage doesn't extend out of the branch block.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://lore.kernel.org/r/20250812104019.605285302@infradead.org
kernel/events/core.c

index e76afd9c17592aa3e82cab9fcd678c3848f9b0e0..875c27b28e9b9a6f2947c04f4de204b6920c4a18 100644 (file)
@@ -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 @@ unlock:
         * 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);