clk: Check for allocation errors in of_clk_init()
A message that is not in the archive (sent off-list or not yet received): 20150610154941.GJ10549@mwanda
PATCH 1/2 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 <[email protected]>
Cc Gregory CLEMENT <[email protected]>
--- drivers/clk/clk.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/clk/clk.c +11 -2
@@ -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;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/2 clk: Move clk_provider_list to scope of function using it
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 <[email protected]>
Signed-off-by Stephen Boyd <[email protected]>
--- drivers/clk/clk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/clk.c +1 -2
@@ -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;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project