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 <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2169624
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
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vinod G
2019-08-06 14:48:14 -07:00
committed by mobile promotions
parent a2689970dc
commit 149f9d826a

View File

@@ -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;