From 92a7cebea6f0240c0e8d8a50af96d6a5c8b2a6e6 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 3 May 2019 17:03:26 +0530 Subject: [PATCH] gpu: nvgpu: fix MISRA 17.7 violation in gr.obj_ctx unit Below MISRA 17.7 violation is reported in common.gr.obj_ctx unit nvgpu/drivers/gpu/nvgpu/common/gr/obj_ctx.c:603: misra_c_2012_rule_17_7: The return value of a non-void function "nvgpu_gr_obj_ctx_init_ctxsw_preemption_mode" is unused. Fix this by adding a check for return value of above function Jira NVGPU-3407 Change-Id: I53467ab3e5ff9dc9dd7f194b3d67649f81fa0546 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/2114365 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/obj_ctx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/obj_ctx.c b/drivers/gpu/nvgpu/common/gr/obj_ctx.c index 05c363e48..70653fde0 100644 --- a/drivers/gpu/nvgpu/common/gr/obj_ctx.c +++ b/drivers/gpu/nvgpu/common/gr/obj_ctx.c @@ -578,8 +578,7 @@ int nvgpu_gr_obj_ctx_alloc(struct gk20a *g, err = nvgpu_gr_obj_ctx_gr_ctx_alloc(g, golden_image, gr_ctx_desc, gr_ctx, vm); if (err != 0) { - nvgpu_err(g, - "fail to allocate TSG gr ctx buffer"); + nvgpu_err(g, "fail to allocate TSG gr ctx buffer"); goto out; } @@ -594,27 +593,30 @@ int nvgpu_gr_obj_ctx_alloc(struct gk20a *g, err = nvgpu_gr_ctx_alloc_patch_ctx(g, gr_ctx, gr_ctx_desc, vm); if (err != 0) { - nvgpu_err(g, - "fail to allocate patch buffer"); + nvgpu_err(g, "fail to allocate patch buffer"); goto out; } } - nvgpu_gr_obj_ctx_init_ctxsw_preemption_mode(g, config, gr_ctx_desc, - gr_ctx, vm, class_num, flags); + err = nvgpu_gr_obj_ctx_init_ctxsw_preemption_mode(g, config, + gr_ctx_desc, gr_ctx, vm, class_num, flags); + if (err != 0) { + nvgpu_err(g, "fail to init preemption mode"); + goto out; + } /* map global buffer to channel gpu_va and commit */ err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_ctx_buffer, vm, vpr); if (err != 0) { - nvgpu_err(g, - "fail to map global ctx buffer"); + nvgpu_err(g, "fail to map global ctx buffer"); goto out; } err = nvgpu_gr_obj_ctx_commit_global_ctx_buffers(g, global_ctx_buffer, config, gr_ctx, true); if (err != 0) { + nvgpu_err(g, "fail to commit global ctx buffer"); goto out; } @@ -626,8 +628,7 @@ int nvgpu_gr_obj_ctx_alloc(struct gk20a *g, err = nvgpu_gr_obj_ctx_alloc_golden_ctx_image(g, golden_image, global_ctx_buffer, config, gr_ctx, inst_block); if (err != 0) { - nvgpu_err(g, - "fail to init golden ctx image"); + nvgpu_err(g, "fail to init golden ctx image"); goto out; } @@ -635,8 +636,7 @@ int nvgpu_gr_obj_ctx_alloc(struct gk20a *g, err = nvgpu_gr_ctx_load_golden_ctx_image(g, gr_ctx, golden_image->local_golden_image, cde); if (err != 0) { - nvgpu_err(g, - "fail to load golden ctx image"); + nvgpu_err(g, "fail to load golden ctx image"); goto out; }