From 4decbdcf732efeb9eb08806f17efcbba7a83a458 Mon Sep 17 00:00:00 2001 From: atanand Date: Wed, 17 Aug 2022 07:29:12 +0000 Subject: [PATCH] nvgpu: fix coverity issue Fixed null pointer dereference. tsg pointer can be null when channel is not bound to tsg. CID 10157561 Bug 3461002 Change-Id: Icf1c19f1840effe0b1f2dc19766c60bf20c73cae Signed-off-by: atanand Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2762161 Reviewed-by: V M S Seeta Rama Raju Mudundi Reviewed-by: Prateek Sethi Reviewed-by: Vaibhav Kachore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/hal/gr/gr/gr_ga10b.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/hal/gr/gr/gr_ga10b.c b/drivers/gpu/nvgpu/hal/gr/gr/gr_ga10b.c index e15b88446..e3071279e 100644 --- a/drivers/gpu/nvgpu/hal/gr/gr/gr_ga10b.c +++ b/drivers/gpu/nvgpu/hal/gr/gr/gr_ga10b.c @@ -1127,9 +1127,14 @@ int ga10b_gr_set_sched_wait_for_errbar(struct gk20a *g, struct nvgpu_tsg *tsg = nvgpu_tsg_from_ch(ch); u32 flags = NVGPU_REG_OP_FLAG_MODE_ALL_OR_NONE; - err = gr_gk20a_exec_ctx_ops(tsg, &ctx_ops, 1, 1, 0, &flags); - if (err != 0) { - nvgpu_err(g, "update implicit ERRBAR failed"); + if (tsg != NULL) { + err = gr_gk20a_exec_ctx_ops(tsg, &ctx_ops, 1, 1, 0, &flags); + if (err != 0) { + nvgpu_err(g, "update implicit ERRBAR failed"); + } + } else { + nvgpu_err(g, "chid: %d is not bound to tsg", ch->chid); + return -EINVAL; } return err; }