diff options
author | Alex Waterman <alexw@nvidia.com> | 2016-08-30 16:23:59 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-08-31 17:04:11 -0400 |
commit | 9247b610d201092c8f64b67dc141d2db66982aeb (patch) | |
tree | 489558823b8f4bdb7e7c2d254667606c74020b56 /drivers/gpu/nvgpu/gk20a | |
parent | a3452ea763d666410e7b898e40b24f07e2cb1045 (diff) |
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 <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1210316
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachit Kadle <skadle@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | 7 |
1 files changed, 5 insertions, 2 deletions
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, | |||
1101 | u64 max_order, u64 flags) | 1101 | u64 max_order, u64 flags) |
1102 | { | 1102 | { |
1103 | int err; | 1103 | int err; |
1104 | u64 pde_size; | ||
1104 | struct gk20a_buddy_allocator *a; | 1105 | struct gk20a_buddy_allocator *a; |
1105 | 1106 | ||
1106 | /* blk_size must be greater than 0 and a power of 2. */ | 1107 | /* 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, | |||
1140 | } | 1141 | } |
1141 | 1142 | ||
1142 | a->vm = vm; | 1143 | a->vm = vm; |
1143 | if (flags & GPU_ALLOC_GVA_SPACE) | 1144 | if (flags & GPU_ALLOC_GVA_SPACE) { |
1144 | a->pte_blk_order = balloc_get_order(a, vm->big_page_size << 10); | 1145 | pde_size = ((u64)vm->big_page_size) << 10; |
1146 | a->pte_blk_order = balloc_get_order(a, pde_size); | ||
1147 | } | ||
1145 | 1148 | ||
1146 | /* | 1149 | /* |
1147 | * When we have a GVA space with big_pages enabled the size and base | 1150 | * When we have a GVA space with big_pages enabled the size and base |