From d6e46c4d37fb29eb552da500243feca9f2bb56e6 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 8 Mar 2017 15:18:06 +0530 Subject: gpu: nvgpu: check return value of mutex_init in dbg_gpu_gk20a.c - check return value of nvgpu_mutex_init in dbg_gpu_gk20a.c - add corresponding nvgpu_mutex_destroy calls Jira NVGPU-13 Change-Id: I153ef2dd17d0fe17b3f38f6fa7e165d1aeaa2a42 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1317135 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: Navneet Kumar --- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 6a32d727..821951ad 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -118,12 +118,22 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, init_waitqueue_head(&dbg_session->dbg_events.wait_queue); INIT_LIST_HEAD(&dbg_session->ch_list); - nvgpu_mutex_init(&dbg_session->ch_list_lock); - nvgpu_mutex_init(&dbg_session->ioctl_lock); + err = nvgpu_mutex_init(&dbg_session->ch_list_lock); + if (err) + goto err_free_session; + err = nvgpu_mutex_init(&dbg_session->ioctl_lock); + if (err) + goto err_destroy_lock; dbg_session->dbg_events.events_enabled = false; dbg_session->dbg_events.num_pending_events = 0; return 0; + +err_destroy_lock: + nvgpu_mutex_destroy(&dbg_session->ch_list_lock); +err_free_session: + kfree(dbg_session); + return err; } /* used in scenarios where the debugger session can take just the inter-session @@ -480,6 +490,9 @@ int gk20a_dbg_gpu_dev_release(struct inode *inode, struct file *filp) nvgpu_dbg_timeout_enable(dbg_s, NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE); nvgpu_mutex_release(&g->dbg_sessions_lock); + nvgpu_mutex_destroy(&dbg_s->ch_list_lock); + nvgpu_mutex_destroy(&dbg_s->ioctl_lock); + kfree(dbg_s); return 0; } -- cgit v1.2.2