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.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJP81RmAAoJEDqPOy9afJhJob4P/j3IAxlWm5Pe/TS37MB+SdZg
 CGRwOXtEoLRTrWNvTWGar9Ph+jN7onQsbAdi+GOsffnY12rg9GCA0oq5irzHHGWq
 r3pv1oFDj8tF6Y1iNFswbBWlZxmIQVWb18r8z8bUBsrdLLYLLa+dOBgcLUO1qin0
 pJ70RZE0Gd0DjElNXuO2rPigueeO3GMVaasNacTmSgv5wAQteMfUQcmvOBEf2Yh2
 Wi064oMBYUHEUCCVyBfqUNPn+e+kB8oN2cvVxigUh+Nbw0QtgR5015XZabMre+3S
 fbhZmoHVGhuAnNLEe0VoQjA7lRG/JKJmYVB3xa9Pk4CgGXEs5dJe5LhSxM4gg+W3
 Uo0op6QDmIEpxeb3/7DALbmHpceiVZWOB9UJyK6ZD0iG961CBO9eumjuWP6QywiE
 sg5ijx0KZ6ssSyKP7yBWW52z2CxraXJsrwdMQCcXAKXOSOlNjQOR0lr4pbMfbIiz
 zZ20opZur+BIugt7GKBt4tn4z/9+c49GS6akVGSlYVqszVLo8g4fdkSw3lYlN3jy
 XhMKvey3nWmia5BYabpdsOWhvntVPeT86iCJdpONvkiYYm2Vkm/1CSQeom4vVRep
 kUjxMLApkuJ5KB/YLuqjOfPsqglPiqzmn5UkvBZ2ZDakpFbIo/s6Z9zWR4hMw/J7
 F4uArxEHITMJutHO6msD
 =0z1d
 -----END PGP SIGNATURE-----

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()
This commit is contained in:
Linus Torvalds 2012-07-03 18:06:49 -07:00
commit 9e85a6f9dc
1 changed files with 13 additions and 15 deletions

View File

@ -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",