diff options
| author | Andrii Nakryiko <[email protected]> | 2024-04-30 20:19:52 +0000 |
|---|---|---|
| committer | Martin KaFai Lau <[email protected]> | 2024-05-02 23:41:03 +0000 |
| commit | 087d757fb4736ecbd3e42eebf9b39d5225d4a2ee (patch) | |
| tree | f3cbe0b31c148fc7e2957e0bb2874ab8c4d10a6c | |
| parent | libbpf: fix potential overflow in ring__consume_n() (diff) | |
| download | kernel-087d757fb4736ecbd3e42eebf9b39d5225d4a2ee.tar.gz kernel-087d757fb4736ecbd3e42eebf9b39d5225d4a2ee.zip | |
libbpf: fix ring_buffer__consume_n() return result logic
Add INT_MAX check to ring_buffer__consume_n(). We do the similar check
to handle int return result of all these ring buffer APIs in other APIs
and ring_buffer__consume_n() is missing one. This patch fixes this
omission.
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: Kumar Kartikeya Dwivedi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
| -rw-r--r-- | tools/lib/bpf/ringbuf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c index 37c5a2d86a78..bfd8dac4c0cc 100644 --- a/tools/lib/bpf/ringbuf.c +++ b/tools/lib/bpf/ringbuf.c @@ -301,7 +301,7 @@ int ring_buffer__consume_n(struct ring_buffer *rb, size_t n) if (n == 0) break; } - return res; + return res > INT_MAX ? INT_MAX : res; } /* Consume available ring buffer(s) data without event polling. |
