From c3f7d9a3b06369e3b554b2d3e36beb346577e4fc Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Tue, 21 May 2019 16:45:39 -0700 Subject: [PATCH] gpu: nvgpu: fix MISRA 17.7 in common.sec2.allocator MISRA Rule 17.7 doesn't allow return value of a function to be ignored. This patch checks return value of nvgpu_allocator_init function and returns error to the sec2_process_init_msg() function. Jira NVGPU-3321 Change-Id: Ie3eb1b5f9312e178f8f3e6de310d768c3ac3e220 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/2123221 Reviewed-by: svc-mobile-coverity Reviewed-by: Philip Elcan Reviewed-by: svc-mobile-misra Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/sec2/ipc/sec2_msg.c | 6 +++++- drivers/gpu/nvgpu/common/sec2/sec2_allocator.c | 9 +++++++-- drivers/gpu/nvgpu/include/nvgpu/sec2/allocator.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/sec2/ipc/sec2_msg.c b/drivers/gpu/nvgpu/common/sec2/ipc/sec2_msg.c index 1ecc248bf..7a8e5836f 100644 --- a/drivers/gpu/nvgpu/common/sec2/ipc/sec2_msg.c +++ b/drivers/gpu/nvgpu/common/sec2/ipc/sec2_msg.c @@ -158,7 +158,11 @@ static int sec2_process_init_msg(struct nvgpu_sec2 *sec2, return err; } - nvgpu_sec2_dmem_allocator_init(g, &sec2->dmem, sec2_init); + err = nvgpu_sec2_dmem_allocator_init(g, &sec2->dmem, sec2_init); + if (err != 0) { + nvgpu_sec2_queues_free(g, sec2->queues); + return err; + } sec2->sec2_ready = true; diff --git a/drivers/gpu/nvgpu/common/sec2/sec2_allocator.c b/drivers/gpu/nvgpu/common/sec2/sec2_allocator.c index ea1ff1543..cf5b52d1a 100644 --- a/drivers/gpu/nvgpu/common/sec2/sec2_allocator.c +++ b/drivers/gpu/nvgpu/common/sec2/sec2_allocator.c @@ -24,10 +24,11 @@ #include #include -void nvgpu_sec2_dmem_allocator_init(struct gk20a *g, +int nvgpu_sec2_dmem_allocator_init(struct gk20a *g, struct nvgpu_allocator *dmem, struct sec2_init_msg_sec2_init *sec2_init) { + int err = 0; if (!nvgpu_alloc_initialized(dmem)) { /* Align start and end addresses */ u32 start = ALIGN(sec2_init->nv_managed_area_offset, @@ -38,10 +39,14 @@ void nvgpu_sec2_dmem_allocator_init(struct gk20a *g, ~(PMU_DMEM_ALLOC_ALIGNMENT - 1U); u32 size = end - start; - nvgpu_allocator_init(g, dmem, NULL, "sec2_dmem", start, + err = nvgpu_allocator_init(g, dmem, NULL, "sec2_dmem", start, size, PMU_DMEM_ALLOC_ALIGNMENT, 0ULL, 0ULL, BITMAP_ALLOCATOR); + if (err != 0) { + nvgpu_err(g, "Couldn't init sec2_dmem allocator\n"); + } } + return err; } void nvgpu_sec2_dmem_allocator_destroy(struct nvgpu_allocator *dmem) diff --git a/drivers/gpu/nvgpu/include/nvgpu/sec2/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/sec2/allocator.h index 8eff1020f..5b97f6e80 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/sec2/allocator.h +++ b/drivers/gpu/nvgpu/include/nvgpu/sec2/allocator.h @@ -27,7 +27,7 @@ struct gk20a; struct nvgpu_allocator; struct sec2_init_msg_sec2_init; -void nvgpu_sec2_dmem_allocator_init(struct gk20a *g, +int nvgpu_sec2_dmem_allocator_init(struct gk20a *g, struct nvgpu_allocator *dmem, struct sec2_init_msg_sec2_init *sec2_init); void nvgpu_sec2_dmem_allocator_destroy(struct nvgpu_allocator *dmem);