From 7dfc81d66306fd0576677f43cc3d4c5cf7e95193 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 8 Mar 2017 15:19:16 +0530 Subject: gpu: nvgpu: check return value of mutex_init in fecs_trace_gk20a.c - check return value of nvgpu_mutex_init in fecs_trace_gk20a.c - add corresponding nvgpu_mutex_destroy calls Jira NVGPU-13 Change-Id: I1fe9dd31bbc084bf66dd73dd26b395d898fde9c4 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1317136 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: Navneet Kumar --- drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c index 05c53a66..2c88b08e 100644 --- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c @@ -573,15 +573,20 @@ static int gk20a_fecs_trace_init(struct gk20a *g) } g->fecs_trace = trace; + err = nvgpu_mutex_init(&trace->poll_lock); + if (err) + goto clean; + err = nvgpu_mutex_init(&trace->hash_lock); + if (err) + goto clean_poll_lock; + BUG_ON(!is_power_of_2(GK20A_FECS_TRACE_NUM_RECORDS)); err = gk20a_fecs_trace_alloc_ring(g); if (err) { gk20a_warn(dev_from_gk20a(g), "failed to allocate FECS ring"); - goto clean; + goto clean_hash_lock; } - nvgpu_mutex_init(&trace->poll_lock); - nvgpu_mutex_init(&trace->hash_lock); hash_init(trace->pid_hash_table); g->gpu_characteristics.flags |= @@ -590,6 +595,10 @@ static int gk20a_fecs_trace_init(struct gk20a *g) gk20a_fecs_trace_debugfs_init(g); return 0; +clean_hash_lock: + nvgpu_mutex_destroy(&trace->hash_lock); +clean_poll_lock: + nvgpu_mutex_destroy(&trace->poll_lock); clean: kfree(trace); g->fecs_trace = NULL; @@ -700,6 +709,9 @@ static int gk20a_fecs_trace_deinit(struct gk20a *g) gk20a_fecs_trace_free_ring(g); gk20a_fecs_trace_free_hash_table(g); + nvgpu_mutex_destroy(&g->fecs_trace->hash_lock); + nvgpu_mutex_destroy(&g->fecs_trace->poll_lock); + kfree(g->fecs_trace); g->fecs_trace = NULL; return 0; -- cgit v1.2.2