From 4874324ee54bcac7b6b07e44a86aa7f16029793e Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Mon, 16 Sep 2019 12:24:20 -0400 Subject: [PATCH] gpu: nvgpu: whitelist MISRA 14.3 bugs Whitelist MISRA Rule 14.3 violations that are due to a bug in the Coverity scanner documented in nvbug 2615925. JIRA NVGPU-4031 Change-Id: Ib8e03641578f27a774b05758cb292236f720c3ba Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/2198904 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/allocators/bitmap_allocator.c | 2 ++ drivers/gpu/nvgpu/include/nvgpu/static_analysis.h | 1 + drivers/gpu/nvgpu/os/posix/bitmap.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/gpu/nvgpu/common/mm/allocators/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/allocators/bitmap_allocator.c index cfabf9892..926fd7d98 100644 --- a/drivers/gpu/nvgpu/common/mm/allocators/bitmap_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/allocators/bitmap_allocator.c @@ -95,6 +95,7 @@ static u64 nvgpu_bitmap_balloc_fixed(struct nvgpu_allocator *na, a->bytes_alloced = nvgpu_safe_add_u64(a->bytes_alloced, nvgpu_safe_mult_u64(blks, a->blk_size)); +NVGPU_COV_WHITELIST(false_positive, NVGPU_MISRA(Rule, 14_3), "Bug 2615925") nvgpu_assert(a->nr_fixed_allocs < U64_MAX); a->nr_fixed_allocs++; alloc_unlock(na); @@ -272,6 +273,7 @@ static u64 nvgpu_bitmap_balloc(struct nvgpu_allocator *na, u64 len) alloc_dbg(na, "Alloc 0x%-10llx 0x%-5llx [bits=0x%x (%u)]", addr, len, blks, blks); +NVGPU_COV_WHITELIST(false_positive, NVGPU_MISRA(Rule, 14_3), "Bug 2615925") nvgpu_assert(a->nr_allocs < U64_MAX); a->nr_allocs++; a->bytes_alloced = nvgpu_safe_add_u64(a->bytes_alloced, diff --git a/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h b/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h index 0a077eee3..e33c4e819 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h +++ b/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h @@ -366,6 +366,7 @@ static inline s32 nvgpu_safe_cast_u64_to_s32(u64 ul_a) static inline s64 nvgpu_safe_cast_u64_to_s64(u64 ul_a) { +NVGPU_COV_WHITELIST(false_positive, NVGPU_MISRA(Rule, 14_3), "Bug 2615925") if (ul_a > LONG_MAX) { BUG(); } else { diff --git a/drivers/gpu/nvgpu/os/posix/bitmap.c b/drivers/gpu/nvgpu/os/posix/bitmap.c index 27dcc74bb..1b436d92c 100644 --- a/drivers/gpu/nvgpu/os/posix/bitmap.c +++ b/drivers/gpu/nvgpu/os/posix/bitmap.c @@ -40,6 +40,7 @@ unsigned long nvgpu_posix_ffs(unsigned long word) nvgpu_safe_cast_u64_to_s64( (word & (unsigned long) LONG_MAX))); } else { +NVGPU_COV_WHITELIST(false_positive, NVGPU_MISRA(Rule, 14_3), "Bug 2615925") if (word > (unsigned long) LONG_MAX) { ret = (int) 64; }