Skip to content

Commit 0ca4da2

Browse files
ahunter6Peter Zijlstra
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 43deb76 commit 0ca4da2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/events/ring_buffer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
682682
if (!has_aux(event))
683683
return -EOPNOTSUPP;
684684

685+
if (nr_pages <= 0)
686+
return -EINVAL;
687+
685688
if (!overwrite) {
686689
/*
687690
* Watermark defaults to half the buffer, and so does the

0 commit comments

Comments
 (0)