From d256b2aa5246af46ae6e3a938ba0f974254a5910 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 31 Oct 2017 00:53:45 -0700 Subject: gpu: nvgpu: fix mutex leak on fecs_mutex In gk20a_gr_reset(), we acquire g->gr.fecs_mutex and call a bunch of APIs But in case any of these APIs fail, we don't release the mutex and just return the error leaking the mutex So the next attempt to acquire g->gr.fecs_mutex results in a deadlock Fix this by releasing the mutex before returning error Bug 2015370 Change-Id: I9a0214ff53515f819c6566c7d44d1898027416e1 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1589062 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index e30c595e..2a20c2d9 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -5057,16 +5057,22 @@ int gk20a_gr_reset(struct gk20a *g) nvgpu_mutex_acquire(&g->gr.fecs_mutex); err = gk20a_enable_gr_hw(g); - if (err) + if (err) { + nvgpu_mutex_release(&g->gr.fecs_mutex); return err; + } err = gk20a_init_gr_setup_hw(g); - if (err) + if (err) { + nvgpu_mutex_release(&g->gr.fecs_mutex); return err; + } err = gr_gk20a_init_ctxsw(g); - if (err) + if (err) { + nvgpu_mutex_release(&g->gr.fecs_mutex); return err; + } nvgpu_mutex_release(&g->gr.fecs_mutex); -- cgit v1.2.2