From 49739b9ee4e32430bc4ec642e7a74f6ba9e853f7 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Fri, 24 May 2019 11:35:27 -0400 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/2125027 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/gmmu/page_table.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c index 1d460f8e3..2e8db5bea 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c @@ -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)), - nvgpu_pd_offset_from_index(l, pd_idx)); - pte_size = (u32)(l->entry_size / sizeof(u32)); + pd->mem_offs / (u32)sizeof(u32), + nvgpu_pd_offset_from_index(l, pd_idx)); + pte_size = l->entry_size / (u32)sizeof(u32); if (data != NULL) { for (i = 0; i < pte_size; i++) {