pinctrl: qcom: Don't iterate past end of function array

Timur reports that this code crashes if nfunctions is 0. Fix the
loop iteration to only consider valid elements of the functions
array.

Reported-by: Timur Tabi <[email protected]>
Cc: Pramod Gurav <[email protected]>
Cc: Bjorn Andersson <[email protected]>
Cc: Ivan T. Ivanov <[email protected]>
Cc: Andy Gross <[email protected]>
Fixes: 327455817a "pinctrl: qcom: Add support for reset for apq8064"
Signed-off-by: Stephen Boyd <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
This commit is contained in:
Stephen Boyd 2015-01-19 11:17:45 +01:00 • committed by Linus Walleij
commit bcd53f858d

View file

@ -865,10 +865,10 @@ static int msm_ps_hold_restart(struct notifier_block *nb, unsigned long action,
static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
{
int i = 0;
int i;
const struct msm_function *func = pctrl->soc->functions;
for (; i <= pctrl->soc->nfunctions; i++)
for (i = 0; i < pctrl->soc->nfunctions; i++)
if (!strcmp(func[i].name, "ps_hold")) {
pctrl->restart_nb.notifier_call = msm_ps_hold_restart;
pctrl->restart_nb.priority = 128;