Skip to content

Commit faac360

Browse files
mszyprowSylwester Nawrocki
authored andcommitted
clk: samsung: exynos5433: Fix error paths
Add checking the value returned by samsung_clk_alloc_reg_dump() and devm_kcalloc(). While fixing this, also release all gathered clocks. Fixes: 523d3de ("clk: samsung: exynos5433: Add support for runtime PM") Signed-off-by: Marek Szyprowski <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Acked-by: Chanwoo Choi <[email protected]> [s.nawrocki: squashed patch from K. Kozlowski adding missing slab.h header] Reported-by: kbuild test robot <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sylwester Nawrocki <[email protected]>
1 parent 54ecb8f commit faac360

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/clk/samsung/clk-exynos5433.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_device.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/pm_runtime.h>
16+
#include <linux/slab.h>
1617

1718
#include <dt-bindings/clock/exynos5433.h>
1819

@@ -5584,6 +5585,8 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev)
55845585

55855586
data->clk_save = samsung_clk_alloc_reg_dump(info->clk_regs,
55865587
info->nr_clk_regs);
5588+
if (!data->clk_save)
5589+
return -ENOMEM;
55875590
data->nr_clk_save = info->nr_clk_regs;
55885591
data->clk_suspend = info->suspend_regs;
55895592
data->nr_clk_suspend = info->nr_suspend_regs;
@@ -5592,12 +5595,19 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev)
55925595
if (data->nr_pclks > 0) {
55935596
data->pclks = devm_kcalloc(dev, sizeof(struct clk *),
55945597
data->nr_pclks, GFP_KERNEL);
5595-
5598+
if (!data->pclks) {
5599+
kfree(data->clk_save);
5600+
return -ENOMEM;
5601+
}
55965602
for (i = 0; i < data->nr_pclks; i++) {
55975603
struct clk *clk = of_clk_get(dev->of_node, i);
55985604

5599-
if (IS_ERR(clk))
5605+
if (IS_ERR(clk)) {
5606+
kfree(data->clk_save);
5607+
while (--i >= 0)
5608+
clk_put(data->pclks[i]);
56005609
return PTR_ERR(clk);
5610+
}
56015611
data->pclks[i] = clk;
56025612
}
56035613
}

0 commit comments

Comments
 (0)