perf/core: Bail out early if the request AUX area is out of bound
[linux-2.6-microblaze.git] / kernel / events / ring_buffer.c
index fb1e180..e8d82c2 100644 (file)
@@ -700,6 +700,12 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
                watermark = 0;
        }
 
+       /*
+        * kcalloc_node() is unable to allocate buffer if the size is larger
+        * than: PAGE_SIZE << MAX_ORDER; directly bail out in this case.
+        */
+       if (get_order((unsigned long)nr_pages * sizeof(void *)) > MAX_ORDER)
+               return -ENOMEM;
        rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
                                     node);
        if (!rb->aux_pages)