mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
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:
committed by
Alex Waterman
parent
3eaf08f06f
commit
38cc3ed48f
@@ -442,7 +442,7 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
|
|||||||
|
|
||||||
if (base == 0ULL) {
|
if (base == 0ULL) {
|
||||||
base = blk_size;
|
base = blk_size;
|
||||||
length -= blk_size;
|
length = nvgpu_safe_sub_u64(length, blk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
a = nvgpu_kzalloc(g, sizeof(struct nvgpu_bitmap_allocator));
|
a = nvgpu_kzalloc(g, sizeof(struct nvgpu_bitmap_allocator));
|
||||||
|
|||||||
@@ -1393,7 +1393,7 @@ static int nvgpu_buddy_set_attributes(struct nvgpu_buddy_allocator *a,
|
|||||||
a->base = base;
|
a->base = base;
|
||||||
a->length = size;
|
a->length = size;
|
||||||
a->blk_size = blk_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;
|
a->owner = na;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1402,7 +1402,7 @@ static int nvgpu_buddy_set_attributes(struct nvgpu_buddy_allocator *a,
|
|||||||
*/
|
*/
|
||||||
if (a->base == 0U) {
|
if (a->base == 0U) {
|
||||||
a->base = a->blk_size;
|
a->base = a->blk_size;
|
||||||
a->length -= a->blk_size;
|
a->length = nvgpu_safe_sub_u64(a->length, a->blk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
a->vm = vm;
|
a->vm = vm;
|
||||||
|
|||||||
Reference in New Issue
Block a user