gpu: nvgpu: Fix overflow of alloc length
Alex Waterman [Tue, 26 May 2015 22:15:56 +0000 (15:15 -0700)]
Fix an issue where large ( > 4GB) allocations were not being computed
correctly. The two fields, pages and page_size, were both 32 bits so
when multiplied they easily overflowed. Simple fix is to cast them to
64 bits before multiplying them.

Change-Id: I63fa54679e485de5c3a99684cbeb72c6cdc65504
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/747429
Reviewed-by: Sami Kiminki <skiminki@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/gpu/nvgpu/gk20a/mm_gk20a.c

index c56cada..5e11a5c 100644 (file)
@@ -2756,7 +2756,9 @@ int gk20a_vm_alloc_space(struct gk20a_as_share *as_share,
                                                 (u64)args->pages *
                                                 (u64)args->page_size);
        else
-               vaddr_start = gk20a_balloc(vma, args->pages * args->page_size);
+               vaddr_start = gk20a_balloc(vma,
+                                          (u64)args->pages *
+                                          (u64)args->page_size);
 
        if (!vaddr_start) {
                kfree(va_node);