gpu: nvgpu: fix the ce app ctx cleanup

tsg and ch members in ce_ctx may remain uninitialized when the cleanup
function nvgpu_ce_delete_gpu_context_locked is called. Guard the
references to those.

CID 438091
Bug 3512546

Change-Id: I0ce96f9bad1e4f7fd331171b3f134c48c893839f
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2707470
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Sagar Kamble
2022-05-05 07:01:03 +05:30
committed by mobile promotions
parent 2506dd2b86
commit c32c4025a4

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -217,7 +217,6 @@ static void nvgpu_ce_delete_gpu_context_locked(struct nvgpu_ce_gpu_ctx *ce_ctx)
struct nvgpu_list_node *list = &ce_ctx->list; struct nvgpu_list_node *list = &ce_ctx->list;
ce_ctx->gpu_ctx_state = NVGPU_CE_GPU_CTX_DELETED; ce_ctx->gpu_ctx_state = NVGPU_CE_GPU_CTX_DELETED;
ce_ctx->tsg->abortable = true;
nvgpu_mutex_acquire(&ce_ctx->gpu_ctx_mutex); nvgpu_mutex_acquire(&ce_ctx->gpu_ctx_mutex);
@@ -230,8 +229,14 @@ static void nvgpu_ce_delete_gpu_context_locked(struct nvgpu_ce_gpu_ctx *ce_ctx)
* free the channel * free the channel
* nvgpu_channel_close() will also unbind the channel from TSG * nvgpu_channel_close() will also unbind the channel from TSG
*/ */
if (ce_ctx->ch != NULL) {
nvgpu_channel_close(ce_ctx->ch); nvgpu_channel_close(ce_ctx->ch);
}
if (ce_ctx->tsg != NULL) {
ce_ctx->tsg->abortable = true;
nvgpu_ref_put(&ce_ctx->tsg->refcount, nvgpu_tsg_release); nvgpu_ref_put(&ce_ctx->tsg->refcount, nvgpu_tsg_release);
}
/* housekeeping on app */ /* housekeeping on app */
if ((list->prev != NULL) && (list->next != NULL)) { if ((list->prev != NULL) && (list->next != NULL)) {