From 4099785e2d60377459845b8fa886ab6be1a1d8e4 Mon Sep 17 00:00:00 2001 From: Vijayakumar Date: Thu, 5 Jan 2017 16:20:51 +0530 Subject: gpu: nvgpu: free boardobj if construct hits an err During construct of some VFE/CLK boardobjs, some data is filled after a boardobj allocation is done. Free up boardobj memory if an error is encountered in the data filling. Coverity ID 490171 Coverity ID 490172 Bug 200192125 Change-Id: I20621f7f9f9e379b8dced4905cd417c2ffa905b0 Signed-off-by: Vijayakumar Reviewed-on: http://git-master/r/1280700 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/clk/clk_prog.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/clk/clk_prog.c') diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c index 6b81650e..22add3b0 100644 --- a/drivers/gpu/nvgpu/clk/clk_prog.c +++ b/drivers/gpu/nvgpu/clk/clk_prog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -703,14 +703,22 @@ static u32 clk_prog_construct_1x_master_table(struct gk20a *g, pclkprog->p_slave_entries = (struct ctrl_clk_clk_prog_1x_master_table_slave_entry *) kzalloc(slavesize, GFP_KERNEL); - if (!pclkprog->p_slave_entries) - return -ENOMEM; + + if (!pclkprog->p_slave_entries) { + status = -ENOMEM; + goto exit; + } memset(pclkprog->p_slave_entries, CTRL_CLK_CLK_DOMAIN_INDEX_INVALID, slavesize); memcpy(pclkprog->p_slave_entries, ptmpprog->p_slave_entries, slavesize); +exit: + if (status) { + if (*ppboardobj != NULL) + (*ppboardobj)->destruct(*ppboardobj); + } return status; } -- cgit v1.2.2