diff options
author | Johan Hovold <johan@kernel.org> | 2018-07-03 12:05:48 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-03 17:00:46 -0700 |
commit | 0470189cd9b931a4a22e2d179a788abc47f6e7fc (patch) | |
tree | 98340d6dd1f353a58ca34644865108e46e800a4a | |
parent | 914b4daa9b6d00b520e136e5a10f5286b4d211f3 (diff) | |
download | linux-exynos-0470189cd9b931a4a22e2d179a788abc47f6e7fc.tar.gz linux-exynos-0470189cd9b931a4a22e2d179a788abc47f6e7fc.tar.bz2 linux-exynos-0470189cd9b931a4a22e2d179a788abc47f6e7fc.zip |
misc: sram: enable clock before registering regions
[ Upstream commit d5b9653dd2bb7a2b1c8cc783c5d3b607bbb6b271 ]
Make sure to enable the clock before registering regions and exporting
partitions to user space at which point we must be prepared for I/O.
Fixes: ee895ccdf776 ("misc: sram: fix enabled clock leak on error path")
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/sram.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 4dd0d868ff88..8daefb81ba29 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -391,23 +391,23 @@ static int sram_probe(struct platform_device *pdev) if (IS_ERR(sram->pool)) return PTR_ERR(sram->pool); - ret = sram_reserve_regions(sram, res); - if (ret) - return ret; - sram->clk = devm_clk_get(sram->dev, NULL); if (IS_ERR(sram->clk)) sram->clk = NULL; else clk_prepare_enable(sram->clk); + ret = sram_reserve_regions(sram, res); + if (ret) + goto err_disable_clk; + platform_set_drvdata(pdev, sram); init_func = of_device_get_match_data(&pdev->dev); if (init_func) { ret = init_func(); if (ret) - goto err_disable_clk; + goto err_free_partitions; } dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n", @@ -415,10 +415,11 @@ static int sram_probe(struct platform_device *pdev) return 0; +err_free_partitions: + sram_free_partitions(sram); err_disable_clk: if (sram->clk) clk_disable_unprepare(sram->clk); - sram_free_partitions(sram); return ret; } |