diff options
author | Johan Hovold <johan@kernel.org> | 2018-07-03 06:05:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-06 10:48:15 -0400 |
commit | f294d00961d1d869ecffa60e280eeeee1ccf9a49 (patch) | |
tree | 5b832d2f3b5acce75c164b63a9276955c917518d /drivers/misc/sram.c | |
parent | 3cfaeb33530592b02b2ceb76b379364c55ca612e (diff) |
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 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.
Fixes: 2ae2e28852f2 ("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>
Diffstat (limited to 'drivers/misc/sram.c')
-rw-r--r-- | drivers/misc/sram.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index c5dc6095686a..679647713e36 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c | |||
@@ -407,13 +407,20 @@ static int sram_probe(struct platform_device *pdev) | |||
407 | if (init_func) { | 407 | if (init_func) { |
408 | ret = init_func(); | 408 | ret = init_func(); |
409 | if (ret) | 409 | if (ret) |
410 | return ret; | 410 | goto err_disable_clk; |
411 | } | 411 | } |
412 | 412 | ||
413 | dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n", | 413 | dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n", |
414 | gen_pool_size(sram->pool) / 1024, sram->virt_base); | 414 | gen_pool_size(sram->pool) / 1024, sram->virt_base); |
415 | 415 | ||
416 | return 0; | 416 | return 0; |
417 | |||
418 | err_disable_clk: | ||
419 | if (sram->clk) | ||
420 | clk_disable_unprepare(sram->clk); | ||
421 | sram_free_partitions(sram); | ||
422 | |||
423 | return ret; | ||
417 | } | 424 | } |
418 | 425 | ||
419 | static int sram_remove(struct platform_device *pdev) | 426 | static int sram_remove(struct platform_device *pdev) |