From 149f9d826a4a2b746543dbaa01b64c0043c7e65b Mon Sep 17 00:00:00 2001 From: Vinod G Date: Tue, 6 Aug 2019 14:48:14 -0700 Subject: [PATCH] gpu: nvgpu: fix cert int30 error in gr unit Fix CERT INT30-C violation in gr unit Ensure the unsigned integer operations do not wrap. Jira NVGPU-3854 Change-Id: I2d95eef97aeee0f9bd01f66f13cfc11d2834b550 Signed-off-by: Vinod G Reviewed-on: https://git-master.nvidia.com/r/2169624 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Philip Elcan GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/gr_config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/gr/gr_config.c b/drivers/gpu/nvgpu/common/gr/gr_config.c index 2f9997e50..6e235d7a8 100644 --- a/drivers/gpu/nvgpu/common/gr/gr_config.c +++ b/drivers/gpu/nvgpu/common/gr/gr_config.c @@ -45,7 +45,8 @@ static void gr_config_init_pes_tpc(struct gk20a *g, * TPCs connected to it. */ if (pes_tpc_count != 0U) { - config->gpc_ppc_count[gpc_index]++; + config->gpc_ppc_count[gpc_index] = nvgpu_safe_add_u32( + config->gpc_ppc_count[gpc_index], 1U); } config->pes_tpc_count[pes_index][gpc_index] = pes_tpc_count;