From 9247b610d201092c8f64b67dc141d2db66982aeb Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 30 Aug 2016 13:23:59 -0700 Subject: gpu: nvgpu: Fix possible overflow in buddy allocator Fix a possible overflow in the buddy allocator's initialization code. In practice it should never happen that pde size is greater than 32bits but this makes coverity happy. Coverity ID 54964 Change-Id: I886fd962bb3e9e328f7305bdcf69827979a39a21 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1210316 GVS: Gerrit_Virtual_Submit Reviewed-by: Sachit Kadle Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c index 8cd1bd0b..dd7f4d27 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c @@ -1101,6 +1101,7 @@ int __gk20a_buddy_allocator_init(struct gk20a_allocator *__a, u64 max_order, u64 flags) { int err; + u64 pde_size; struct gk20a_buddy_allocator *a; /* blk_size must be greater than 0 and a power of 2. */ @@ -1140,8 +1141,10 @@ int __gk20a_buddy_allocator_init(struct gk20a_allocator *__a, } a->vm = vm; - if (flags & GPU_ALLOC_GVA_SPACE) - a->pte_blk_order = balloc_get_order(a, vm->big_page_size << 10); + if (flags & GPU_ALLOC_GVA_SPACE) { + pde_size = ((u64)vm->big_page_size) << 10; + a->pte_blk_order = balloc_get_order(a, pde_size); + } /* * When we have a GVA space with big_pages enabled the size and base -- cgit v1.2.2