From bac38f52cc6f2ddc435a748dd9c85f3c5d88153f Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Mon, 3 Sep 2018 10:51:02 +0530 Subject: gpu: nvgpu: protect clk_arb init with mutex. g->clk_arb is currently initialized as a part of gk20a_finalize_poweron(). Any subsequent call to gk20a_finalize_poweron reinitializes the clk_arb and leading to memory leaks. This is resolved by protecting the g->clk_arb initialization with a mutex clk_arb_enable_lock in struct gk20a. We skip initializing the g->clk_arb if its not NULL. Bug 2061372 Change-Id: I59158e0a5e4c827fdbd6d9ea2d04c78d0986347a Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/1811650 Reviewed-by: Deepak Nibade GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/driver_common.c | 1 + drivers/gpu/nvgpu/os/linux/module.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'drivers/gpu/nvgpu/os') diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index 16af2cb0..b81cc90c 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.c +++ b/drivers/gpu/nvgpu/os/linux/driver_common.c @@ -65,6 +65,7 @@ static void nvgpu_init_vars(struct gk20a *g) nvgpu_mutex_init(&g->poweroff_lock); nvgpu_mutex_init(&g->ctxsw_disable_lock); nvgpu_mutex_init(&g->tpc_pg_lock); + nvgpu_mutex_init(&g->clk_arb_enable_lock); l->regs_saved = l->regs; l->bar1_saved = l->bar1; diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index cb501683..d226ceeb 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -1310,6 +1310,8 @@ int nvgpu_remove(struct device *dev, struct class *class) if (platform->remove) platform->remove(dev); + nvgpu_mutex_destroy(&g->clk_arb_enable_lock); + nvgpu_log_fn(g, "removed"); return err; -- cgit v1.2.2