diff options
author | Lakshmanan M <lm@nvidia.com> | 2016-07-20 09:03:57 -0400 |
---|---|---|
committer | Vijayakumar Subbu <vsubbu@nvidia.com> | 2016-07-26 01:39:25 -0400 |
commit | 450aa3f0bec1b5164a0986cd6518ef1937f7c80f (patch) | |
tree | e3ecfd187500fa37bb8b37c7ce370d9aaa54494d /drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | |
parent | 021c23e46eb69ee2c888fa3b05834f110da7a450 (diff) |
gpu: nvgpu: corner case failure handling in CE infra interface
This CL covers the following simple modification,
1) Linux kernel list implementation doesn't handle NULL pointer dereference
at list_del() api.
2) NULL validation before access the command buffer related operations.
This required for prevent the illegal/NULL memory access during
gk20a_ce_create_context_with_cb() failure case.
JIRA DNVGPU-53
Change-Id: I3ad178970ecb1485098124378bfc5256a9455ebd
Signed-off-by: Lakshmanan M <lm@nvidia.com>
Reviewed-on: http://git-master/r/1184294
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ce2_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index a69cce0c..8ea0b2d5 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | |||
@@ -186,20 +186,24 @@ static void gk20a_ce_free_command_buffer_stored_fence(struct gk20a_gpu_ctx *ce_c | |||
186 | /* assume this api should need to call under mutex_lock(&ce_app->app_mutex) */ | 186 | /* assume this api should need to call under mutex_lock(&ce_app->app_mutex) */ |
187 | static void gk20a_ce_delete_gpu_context(struct gk20a_gpu_ctx *ce_ctx) | 187 | static void gk20a_ce_delete_gpu_context(struct gk20a_gpu_ctx *ce_ctx) |
188 | { | 188 | { |
189 | struct list_head *list = &ce_ctx->list; | ||
190 | |||
189 | ce_ctx->gpu_ctx_state = NVGPU_CE_GPU_CTX_DELETED; | 191 | ce_ctx->gpu_ctx_state = NVGPU_CE_GPU_CTX_DELETED; |
190 | 192 | ||
191 | mutex_lock(&ce_ctx->gpu_ctx_mutex); | 193 | mutex_lock(&ce_ctx->gpu_ctx_mutex); |
192 | 194 | ||
193 | gk20a_ce_free_command_buffer_stored_fence(ce_ctx); | 195 | if (ce_ctx->cmd_buf_mem.cpu_va) { |
194 | 196 | gk20a_ce_free_command_buffer_stored_fence(ce_ctx); | |
195 | gk20a_gmmu_unmap_free(ce_ctx->vm, &ce_ctx->cmd_buf_mem); | 197 | gk20a_gmmu_unmap_free(ce_ctx->vm, &ce_ctx->cmd_buf_mem); |
198 | } | ||
196 | 199 | ||
197 | /* free the channel */ | 200 | /* free the channel */ |
198 | if (ce_ctx->ch) | 201 | if (ce_ctx->ch) |
199 | gk20a_channel_close(ce_ctx->ch); | 202 | gk20a_channel_close(ce_ctx->ch); |
200 | 203 | ||
201 | /* housekeeping on app */ | 204 | /* housekeeping on app */ |
202 | list_del(&ce_ctx->list); | 205 | if (list->prev && list->next) |
206 | list_del(list); | ||
203 | 207 | ||
204 | mutex_unlock(&ce_ctx->gpu_ctx_mutex); | 208 | mutex_unlock(&ce_ctx->gpu_ctx_mutex); |
205 | mutex_destroy(&ce_ctx->gpu_ctx_mutex); | 209 | mutex_destroy(&ce_ctx->gpu_ctx_mutex); |