summaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-02-03 12:43:11 -0800
committerStephen Boyd <sboyd@codeaurora.org>2017-02-06 14:48:32 -0800
commit5d806f9fc8e63d7a44e0fd1ef26a7c27efae0e51 (patch)
tree9b4313c80e5a6f8f2ba0822ba2d46c0c162706aa /drivers/clk
parentca6f2796eef7fcff66a3b3f4bf45a7493ead0620 (diff)
downloadop-kernel-dev-5d806f9fc8e63d7a44e0fd1ef26a7c27efae0e51.zip
op-kernel-dev-5d806f9fc8e63d7a44e0fd1ef26a7c27efae0e51.tar.gz
clk: sunxi-ng: Check kzalloc() for errors and cleanup error path
This kzalloc() could fail. Let's bail out with -ENOMEM here instead of NULL dereferencing. That silences static checkers. We should also cleanup on the error path even though this function returning an error probably means the system won't boot. Cc: Chen-Yu Tsai <wens@csie.org> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/sunxi-ng/ccu_common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c
index 6986e11e..8a47baf 100644
--- a/drivers/clk/sunxi-ng/ccu_common.c
+++ b/drivers/clk/sunxi-ng/ccu_common.c
@@ -75,6 +75,11 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
goto err_clk_unreg;
reset = kzalloc(sizeof(*reset), GFP_KERNEL);
+ if (!reset) {
+ ret = -ENOMEM;
+ goto err_alloc_reset;
+ }
+
reset->rcdev.of_node = node;
reset->rcdev.ops = &ccu_reset_ops;
reset->rcdev.owner = THIS_MODULE;
@@ -90,6 +95,16 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
return 0;
err_of_clk_unreg:
+ kfree(reset);
+err_alloc_reset:
+ of_clk_del_provider(node);
err_clk_unreg:
+ while (--i >= 0) {
+ struct clk_hw *hw = desc->hw_clks->hws[i];
+
+ if (!hw)
+ continue;
+ clk_hw_unregister(hw);
+ }
return ret;
}
OpenPOWER on IntegriCloud