mm/gup_benchmark.c: prevent integer overflow in ioctl
[linux-2.6-block.git] / mm / gup_benchmark.c
index debf11388a600d0f445ed1ac055e14bf0d55790d..5b42d3d4b60aa3a921002abf8f2872bc6e0764f8 100644 (file)
@@ -27,6 +27,9 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
        int nr;
        struct page **pages;
 
+       if (gup->size > ULONG_MAX)
+               return -EINVAL;
+
        nr_pages = gup->size / PAGE_SIZE;
        pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL);
        if (!pages)