aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2018-07-03 12:05:47 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-22 07:43:43 +0200
commit93e5f3d10e79e64fff32cbd0b6d300b02149a595 (patch)
tree4fbe970271875ea6cbaabc3827b5b2be03db5c68
parent421483e0c44435475e4a3f8f51037010dfa78620 (diff)
downloadlinux-93e5f3d10e79e64fff32cbd0b6d300b02149a595.tar.gz
misc: sram: fix resource leaks in probe error path
commit f294d00961d1d869ecffa60e280eeeee1ccf9a49 upstream. Make sure to disable clocks and deregister any exported partitions before returning on late probe errors. Note that since commit ee895ccdf776 ("misc: sram: fix enabled clock leak on error path"), partitions are deliberately exported before enabling the clock so we stick to that logic here. A follow up patch will address this. Cc: stable <stable@vger.kernel.org> # 4.9 Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/sram.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index c5dc6095686a2..679647713e36f 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -407,13 +407,20 @@ static int sram_probe(struct platform_device *pdev)
if (init_func) {
ret = init_func();
if (ret)
- return ret;
+ goto err_disable_clk;
}
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base);
return 0;
+
+err_disable_clk:
+ if (sram->clk)
+ clk_disable_unprepare(sram->clk);
+ sram_free_partitions(sram);
+
+ return ret;
}
static int sram_remove(struct platform_device *pdev)