misc: sram: fix resource leaks in probe error path

Make sure to disable clocks and deregister any exported partitions
before returning on late probe errors.

Note that since commit ee895ccdf7 ("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.

Fixes: 2ae2e28852 ("misc: sram: add Atmel securam support")
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>
This commit is contained in:
Johan Hovold 2018-07-03 12:05:47 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель 3cfaeb3353
Коммит f294d00961
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -407,13 +407,20 @@ static int sram_probe(struct platform_device *pdev)
if (init_func) { if (init_func) {
ret = init_func(); ret = init_func();
if (ret) if (ret)
return ret; goto err_disable_clk;
} }
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n", dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base); gen_pool_size(sram->pool) / 1024, sram->virt_base);
return 0; 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) static int sram_remove(struct platform_device *pdev)