mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: init: fix CERT-C violations
CERT-C INT-30 requires checking if arithmetic operations will wrap. Use the safe ops in hal_init.c to avoid this violation JIRA NVGPU-3847 Change-Id: If6616f7ff9133f652c11325ae04fc7842a0b97a3 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2157278 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
mobile promotions
parent
35b84884da
commit
1551e7ea3d
@@ -27,6 +27,7 @@
|
||||
#include <nvgpu/hal_init.h>
|
||||
#include <nvgpu/mc.h>
|
||||
#include <nvgpu/soc.h>
|
||||
#include <nvgpu/safe_ops.h>
|
||||
|
||||
#include "hal_gm20b.h"
|
||||
#include "hal_gp10b.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
int nvgpu_init_hal(struct gk20a *g)
|
||||
{
|
||||
int err = 0;
|
||||
u32 ver = g->params.gpu_arch + g->params.gpu_impl;
|
||||
u32 ver = nvgpu_safe_add_u32(g->params.gpu_arch, g->params.gpu_impl);
|
||||
|
||||
switch (ver) {
|
||||
#ifdef CONFIG_NVGPU_HAL_NON_FUSA
|
||||
@@ -102,7 +103,8 @@ int nvgpu_detect_chip(struct gk20a *g)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if ((p->gpu_arch + p->gpu_impl) == (u32)NVGPU_GPUID_GV11B) {
|
||||
if (nvgpu_safe_add_u32(p->gpu_arch, p->gpu_impl) ==
|
||||
(u32)NVGPU_GPUID_GV11B) {
|
||||
/* overwrite gpu revison for A02 */
|
||||
if (!nvgpu_is_soc_t194_a01(g)) {
|
||||
p->gpu_rev = 0xa2;
|
||||
|
||||
Reference in New Issue
Block a user