Skip to content

Commit

Permalink
Merge tag 'clk-fixes-for-linus' of git://git.linaro.org/people/mturqu…
Browse files Browse the repository at this point in the history
…ette/linux

Pull fix to common clk framework from Michael Turquette:
 "The previous set of common clk fixes for -rc5 left an uninitialized
  int which could lead to bad array indexing when switching clock
  parents.  The issue is fixed with a trivial change to the code flow in
  __clk_set_parent."

* tag 'clk-fixes-for-linus' of git://git.linaro.org/people/mturquette/linux:
  clk: fix parent validation in __clk_set_parent()
  • Loading branch information
Linus Torvalds committed Jul 4, 2012
2 parents 6c8addc + 863b132 commit 9e85a6f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,26 +1067,24 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)

old_parent = clk->parent;

/* find index of new parent clock using cached parent ptrs */
if (clk->parents)
for (i = 0; i < clk->num_parents; i++)
if (clk->parents[i] == parent)
break;
else
if (!clk->parents)
clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
GFP_KERNEL);

/*
* find index of new parent clock using string name comparison
* also try to cache the parent to avoid future calls to __clk_lookup
* find index of new parent clock using cached parent ptrs,
* or if not yet cached, use string name comparison and cache
* them now to avoid future calls to __clk_lookup.
*/
if (i == clk->num_parents)
for (i = 0; i < clk->num_parents; i++)
if (!strcmp(clk->parent_names[i], parent->name)) {
if (clk->parents)
clk->parents[i] = __clk_lookup(parent->name);
break;
}
for (i = 0; i < clk->num_parents; i++) {
if (clk->parents && clk->parents[i] == parent)
break;
else if (!strcmp(clk->parent_names[i], parent->name)) {
if (clk->parents)
clk->parents[i] = __clk_lookup(parent->name);
break;
}
}

if (i == clk->num_parents) {
pr_debug("%s: clock %s is not a possible parent of clock %s\n",
Expand Down

0 comments on commit 9e85a6f

Please sign in to comment.