All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] clk: Check for allocation errors in of_clk_init()
       [not found] <20150610154941.GJ10549@mwanda>
@ 2015-07-06 23:59 ` Stephen Boyd
  2015-07-06 23:59   ` [PATCH 2/2] clk: Move clk_provider_list to scope of function using it Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Boyd @ 2015-07-06 23:59 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Gregory CLEMENT

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>
---
 drivers/clk/clk.c | 13 +++++++++++--
 1 file 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;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] clk: Move clk_provider_list to scope of function using it
  2015-07-06 23:59 ` [PATCH 1/2] clk: Check for allocation errors in of_clk_init() Stephen Boyd
@ 2015-07-06 23:59   ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2015-07-06 23:59 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Gregory CLEMENT

The list isn't used after of_clk_init() is called, so we don't
need to keep an empty list around after init. Put the list on the
stack.

Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 705156828a7a..7873151a7ff8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3054,8 +3054,6 @@ struct clock_provider {
 	struct list_head node;
 };
 
-static LIST_HEAD(clk_provider_list);
-
 /*
  * This function looks for a parent clock. If there is one, then it
  * checks that the provider for this parent clock was initialized, in
@@ -3106,6 +3104,7 @@ void __init of_clk_init(const struct of_device_id *matches)
 	struct clock_provider *clk_provider, *next;
 	bool is_init_done;
 	bool force = false;
+	LIST_HEAD(clk_provider_list);
 
 	if (!matches)
 		matches = &__clk_of_table;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-06 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20150610154941.GJ10549@mwanda>
2015-07-06 23:59 ` [PATCH 1/2] clk: Check for allocation errors in of_clk_init() Stephen Boyd
2015-07-06 23:59   ` [PATCH 2/2] clk: Move clk_provider_list to scope of function using it Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.