Assigned clocks: fix off-by-one bug, don't leak allocated memory.

MFC after:	1 week
This commit is contained in:
Michal Meloun 2020-07-12 07:42:21 +00:00
parent 6e9862526a
commit a9be5d7515

View File

@ -1420,15 +1420,17 @@ clk_set_assigned(device_t dev, phandle_t node)
}
/* First set it's parent if needed */
if (i <= nparents)
if (i < nparents)
clk_set_assigned_parent(dev, clk, i);
/* Then set a new frequency */
if (i <= nrates && rates[i] != 0)
if (i < nrates && rates[i] != 0)
clk_set_assigned_rates(dev, clk, rates[i]);
clk_release(clk);
}
if (rates != NULL)
OF_prop_free(rates);
return (0);
}