diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 392503dc3..6f9b18e83 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -920,9 +920,7 @@ void nvgpu_tsg_release(struct nvgpu_ref *ref) return; } - if ((tsg->gr_ctx != NULL) && - nvgpu_mem_is_valid(nvgpu_gr_ctx_get_ctx_mem(tsg->gr_ctx)) && - (tsg->vm != NULL)) { + if ((tsg->gr_ctx != NULL) && (tsg->vm != NULL)) { g->ops.gr.setup.free_gr_ctx(g, tsg->vm, tsg->gr_ctx); } diff --git a/drivers/gpu/nvgpu/common/gr/gr_setup.c b/drivers/gpu/nvgpu/common/gr/gr_setup.c index 6d7df6967..71b4e335c 100644 --- a/drivers/gpu/nvgpu/common/gr/gr_setup.c +++ b/drivers/gpu/nvgpu/common/gr/gr_setup.c @@ -262,7 +262,8 @@ void nvgpu_gr_setup_free_gr_ctx(struct gk20a *g, { nvgpu_log_fn(g, " "); - if (gr_ctx != NULL) { + if ((gr_ctx != NULL) && + nvgpu_mem_is_valid(nvgpu_gr_ctx_get_ctx_mem(gr_ctx))) { #ifdef CONFIG_DEBUG_FS if ((g->ops.gr.ctxsw_prog.dump_ctxsw_stats != NULL) && nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close(