Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e3b19f1 authored by Stephen Boyd's avatar Stephen Boyd
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent ca7d07a2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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;