gpu: nvgpu: mm: fix CERT-C INT31 violations in page_table

CERT-C INT31 requires checking that integer conversions do not result in
misinterpreted data. Fix violations in page_table by casting only the
sizeof() operation.

JIRA NVGPU-3515

Change-Id: Id809bd7357702b04e0191477fd0e71881d60ea03
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2125027
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2019-05-24 11:35:27 -04:00
committed by mobile promotions
parent 66c79f3bb3
commit 49739b9ee4

View File

@@ -951,7 +951,7 @@ u32 nvgpu_pte_words(struct gk20a *g)
l++;
} while (true);
return (u32)(l->entry_size / sizeof(u32));
return l->entry_size / (u32)sizeof(u32);
}
/*
@@ -1008,9 +1008,9 @@ static int nvgpu_locate_pte(struct gk20a *g, struct vm_gk20a *vm,
* (due to PD packing).
*/
pte_base = nvgpu_safe_add_u32(
(u32)(pd->mem_offs / sizeof(u32)),
pd->mem_offs / (u32)sizeof(u32),
nvgpu_pd_offset_from_index(l, pd_idx));
pte_size = (u32)(l->entry_size / sizeof(u32));
pte_size = l->entry_size / (u32)sizeof(u32);
if (data != NULL) {
for (i = 0; i < pte_size; i++) {