summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2015-07-07 01:48:19 +0200
committerStephen Boyd <sboyd@codeaurora.org>2015-07-08 02:20:03 +0200
commit2e3b19f137f31290979999ff7ac67ce52e02be0e (patch)
tree5352ee3fb7599ee804129546b816522bd4c3caee /drivers/clk/clk.c
parentMerge branch 'clk-rk3368' into clk-next (diff)
downloadlinux-2e3b19f137f31290979999ff7ac67ce52e02be0e.tar.xz
linux-2e3b19f137f31290979999ff7ac67ce52e02be0e.zip
clk: Check for allocation errors in of_clk_init()
Dan Carpenter reports that we don't check the allocation here for failure. Add a failure check and free any previously allocated providers from the clk_provider_list. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ddb4b541016f..705156828a7a 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3112,8 +3112,17 @@ void __init of_clk_init(const struct of_device_id *matches)
/* First prepare the list of the clocks providers */
for_each_matching_node_and_match(np, matches, &match) {
- struct clock_provider *parent =
- kzalloc(sizeof(struct clock_provider), GFP_KERNEL);
+ struct clock_provider *parent;
+
+ parent = kzalloc(sizeof(*parent), GFP_KERNEL);
+ if (!parent) {
+ list_for_each_entry_safe(clk_provider, next,
+ &clk_provider_list, node) {
+ list_del(&clk_provider->node);
+ kfree(clk_provider);
+ }
+ return;
+ }
parent->clk_init_cb = match->data;
parent->np = np;