On 2/12/2019 9:07 PM, Peter Zijlstra wrote:
On Tue, Feb 12, 2019 at 10:42:38AM +0800, Jin, Yao wrote:
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 4a9937076331..309ef5a64af5 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -734,6 +734,9 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, 
int cpu, int flags)
        size = sizeof(struct ring_buffer);
        size += nr_pages * sizeof(void *);
+       if (order_base_2(size) >= MAX_ORDER)
+               goto fail;
+
        rb = kzalloc(size, GFP_KERNEL);

Yes, Boris also send the entire morning bisecting this.

The problem is that @size is in bytes and MAX_ORDER is in pages.

That should be:

   if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER)



Thanks Peter! This fix works!

Thanks
Jin Yao

Reply via email to