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 <atanand@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2762161
Reviewed-by: V M S Seeta Rama Raju Mudundi <srajum@nvidia.com>
Reviewed-by: Prateek Sethi <prsethi@nvidia.com>
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
atanand
2022-08-17 07:29:12 +00:00
committed by mobile promotions
parent d00a8fd09a
commit 4decbdcf73

View File

@@ -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;
}