From 5ad1c28b5fa7724e7aa65ea1a87a615c0d5408f6 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 2 Jan 2018 02:04:06 -0800 Subject: gpu: nvgpu: fix TSG leak from CE code In gk20a_ce_delete_gpu_context(), we unbind the channel from TSG and close the channel. But we do not drop the TSG refcount leaking the TSG reference Fix this by explicitly dropping TSG refcount Also, do not explicitly unbind the channel from TSG gk20a_channel_close() will internally unbind the channel from TSG Bug 200374011 Change-Id: Ie4aa32f1d0bff4231f41aa2b33743cdc63e967c7 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1629972 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index ec20a679..99a6dd1b 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c @@ -153,13 +153,12 @@ static void gk20a_ce_delete_gpu_context(struct gk20a_gpu_ctx *ce_ctx) nvgpu_dma_unmap_free(ce_ctx->vm, &ce_ctx->cmd_buf_mem); } - /* unbind tsg */ - if (ce_ctx->tsg && ce_ctx->ch) - gk20a_tsg_unbind_channel(ce_ctx->ch); - - /* free the channel */ - if (ce_ctx->ch) - gk20a_channel_close(ce_ctx->ch); + /* + * free the channel + * gk20a_channel_close() will also unbind the channel from TSG + */ + gk20a_channel_close(ce_ctx->ch); + nvgpu_ref_put(&ce_ctx->tsg->refcount, gk20a_tsg_release); /* housekeeping on app */ if (list->prev && list->next) -- cgit v1.2.2