From a2689970dc6986635fb56caf2b11fa6fb5855ae5 Mon Sep 17 00:00:00 2001 From: Vinod G Date: Tue, 6 Aug 2019 15:42:04 -0700 Subject: [PATCH] gpu: nvgpu: fix cert arr37 error in gr unit Fix CERT ARR37-C violations in gr unit cert_arr37_c_violation: Performing pointer arithmetic in expression. Make the pointer operand point to an array using index 0. Jira NVGPU-3854 Change-Id: I11f1d4a3e74f7711f1e3b479785b1dbcc20fee75 Signed-off-by: Vinod G Reviewed-on: https://git-master.nvidia.com/r/2169668 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Philip Elcan GVS: Gerrit_Virtual_Submit Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/bitmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/posix/bitmap.c b/drivers/gpu/nvgpu/os/posix/bitmap.c index de24623e9..27dcc74bb 100644 --- a/drivers/gpu/nvgpu/os/posix/bitmap.c +++ b/drivers/gpu/nvgpu/os/posix/bitmap.c @@ -73,6 +73,7 @@ static unsigned long nvgpu_posix_find_next_bit(const unsigned long *addr, unsigned long idx, idx_max; unsigned long w; unsigned long start_mask; + const unsigned long *base_addr = (const unsigned long *)&addr[0]; /* * We make a mask we can XOR into the word so that we can invert the @@ -96,7 +97,7 @@ static unsigned long nvgpu_posix_find_next_bit(const unsigned long *addr, start_mask = ~0UL << (start & (BITS_PER_LONG - 1UL)); idx = start / BITS_PER_LONG; - w = (addr[idx] ^ invert_mask) & start_mask; + w = (base_addr[idx] ^ invert_mask) & start_mask; start = round_up(start, BITS_PER_LONG); @@ -114,7 +115,7 @@ static unsigned long nvgpu_posix_find_next_bit(const unsigned long *addr, start = nvgpu_safe_add_u64(start, BITS_PER_LONG); - w = addr[idx] ^ invert_mask; + w = base_addr[idx] ^ invert_mask; } return min(n, (nvgpu_safe_add_u64(((nvgpu_ffs(w)) - 1UL),