@@ -1309,6 +1309,8 @@ static struct clk *__clk_init_parent(struct clk *clk)
*/
index = clk->ops->get_parent(clk->hw);
+ if (index >= clk->num_parents)
+ goto out;
if (!clk->parents)
clk->parents =
@@ -1630,8 +1632,9 @@ int __clk_init(struct device *dev, struct clk *clk)
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
if (orphan->ops->get_parent) {
i = orphan->ops->get_parent(orphan->hw);
- if (!strcmp(clk->name, orphan->parent_names[i]))
- __clk_reparent(orphan, clk);
+ if (i < orphan->num_parents)
+ if (!strcmp(clk->name, orphan->parent_names[i]))
+ __clk_reparent(orphan, clk);
continue;
}