gpu: nvgpu: fix CERT-C violations in mm

INT30-C requires that unsigned integer operations do not wrap.

Jira NVGPU-3882

Change-Id: I2424416e79d4203931fd28afc1c9349a746d8f68
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2211033
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2019-10-03 11:28:28 -07:00
committed by Alex Waterman
parent 3eaf08f06f
commit 38cc3ed48f
2 changed files with 3 additions and 3 deletions

View File

@@ -442,7 +442,7 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
if (base == 0ULL) {
base = blk_size;
length -= blk_size;
length = nvgpu_safe_sub_u64(length, blk_size);
}
a = nvgpu_kzalloc(g, sizeof(struct nvgpu_bitmap_allocator));

View File

@@ -1393,7 +1393,7 @@ static int nvgpu_buddy_set_attributes(struct nvgpu_buddy_allocator *a,
a->base = base;
a->length = size;
a->blk_size = blk_size;
a->blk_shift = (nvgpu_ffs(blk_size) - 1UL);
a->blk_shift = nvgpu_safe_sub_u64(nvgpu_ffs(blk_size), 1UL);
a->owner = na;
/*
@@ -1402,7 +1402,7 @@ static int nvgpu_buddy_set_attributes(struct nvgpu_buddy_allocator *a,
*/
if (a->base == 0U) {
a->base = a->blk_size;
a->length -= a->blk_size;
a->length = nvgpu_safe_sub_u64(a->length, a->blk_size);
}
a->vm = vm;