diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-03 21:06:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-03 21:06:49 -0400 |
commit | 9e85a6f9dc231f3ed3c1dc1b12217505d970142a (patch) | |
tree | 2bbdccf469176b0e783e408eb8e2f91d1630797c | |
parent | 6c8addcb7669427d67029c485c8c6ab18470f83f (diff) | |
parent | 863b13271f1608ab3af6f7a371047d9a66693e38 (diff) |
Merge tag 'clk-fixes-for-linus' of git://git.linaro.org/people/mturquette/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()
-rw-r--r-- | drivers/clk/clk.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index dcbe05616090..9a1eb0cfa95f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -1067,26 +1067,24 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) | |||
1067 | 1067 | ||
1068 | old_parent = clk->parent; | 1068 | old_parent = clk->parent; |
1069 | 1069 | ||
1070 | /* find index of new parent clock using cached parent ptrs */ | 1070 | if (!clk->parents) |
1071 | if (clk->parents) | ||
1072 | for (i = 0; i < clk->num_parents; i++) | ||
1073 | if (clk->parents[i] == parent) | ||
1074 | break; | ||
1075 | else | ||
1076 | clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents), | 1071 | clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents), |
1077 | GFP_KERNEL); | 1072 | GFP_KERNEL); |
1078 | 1073 | ||
1079 | /* | 1074 | /* |
1080 | * find index of new parent clock using string name comparison | 1075 | * find index of new parent clock using cached parent ptrs, |
1081 | * also try to cache the parent to avoid future calls to __clk_lookup | 1076 | * or if not yet cached, use string name comparison and cache |
1077 | * them now to avoid future calls to __clk_lookup. | ||
1082 | */ | 1078 | */ |
1083 | if (i == clk->num_parents) | 1079 | for (i = 0; i < clk->num_parents; i++) { |
1084 | for (i = 0; i < clk->num_parents; i++) | 1080 | if (clk->parents && clk->parents[i] == parent) |
1085 | if (!strcmp(clk->parent_names[i], parent->name)) { | 1081 | break; |
1086 | if (clk->parents) | 1082 | else if (!strcmp(clk->parent_names[i], parent->name)) { |
1087 | clk->parents[i] = __clk_lookup(parent->name); | 1083 | if (clk->parents) |
1088 | break; | 1084 | clk->parents[i] = __clk_lookup(parent->name); |
1089 | } | 1085 | break; |
1086 | } | ||
1087 | } | ||
1090 | 1088 | ||
1091 | if (i == clk->num_parents) { | 1089 | if (i == clk->num_parents) { |
1092 | pr_debug("%s: clock %s is not a possible parent of clock %s\n", | 1090 | pr_debug("%s: clock %s is not a possible parent of clock %s\n", |