perf: Make rb_alloc_aux() return an error immediately if nr_pages <= 0

rb_alloc_aux() should not be called with nr_pages <= 0. Make it more robust
and readable by returning an error immediately in that case.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240624201101.60186-8-adrian.hunter@intel.com
This commit is contained in:
Adrian Hunter 2024-06-24 23:11:01 +03:00 committed by Peter Zijlstra
parent 43deb76b19
commit 0ca4da2412

View File

@ -682,6 +682,9 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
if (!has_aux(event)) if (!has_aux(event))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (nr_pages <= 0)
return -EINVAL;
if (!overwrite) { if (!overwrite) {
/* /*
* Watermark defaults to half the buffer, and so does the * Watermark defaults to half the buffer, and so does the