summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2025-08-02 12:39:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-28 16:24:14 +0200
commit899d253add77519da95d6648f24730046dd3411a (patch)
tree1bc76c81fc466fb928d9e63536f3891e34dac9b1 /kernel
parentce0481ac88a7329ca61365296ac4b8a382dbda31 (diff)
downloadlinux-899d253add77519da95d6648f24730046dd3411a.tar.gz
linux-899d253add77519da95d6648f24730046dd3411a.tar.bz2
linux-899d253add77519da95d6648f24730046dd3411a.zip
perf/core: Don't leak AUX buffer refcount on allocation failure
commit 5468c0fbccbb9d156522c50832244a8b722374fb upstream. Failure of the AUX buffer allocation leaks the reference count. Set the reference count to 1 only when the allocation succeeds. Fixes: 45bfb2e50471 ("perf/core: Add AUX area to ring buffer for raw data streams") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3e98d1029314..66982c45ce63 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6477,9 +6477,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
goto unlock;
}
- atomic_set(&rb->aux_mmap_count, 1);
user_extra = nr_pages;
-
goto accounting;
}
@@ -6581,8 +6579,10 @@ accounting:
} else {
ret = rb_alloc_aux(rb, event, vma->vm_pgoff, nr_pages,
event->attr.aux_watermark, flags);
- if (!ret)
+ if (!ret) {
+ atomic_set(&rb->aux_mmap_count, 1);
rb->aux_mmap_locked = extra;
+ }
}
unlock:
@@ -6592,6 +6592,7 @@ unlock:
atomic_inc(&event->mmap_count);
} else if (rb) {
+ /* AUX allocation failed */
atomic_dec(&rb->mmap_count);
}
aux_unlock: