Commit 39b65fbb authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Walleij

pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable()

The pinctrl->functions[] array has pinctrl->num_functions elements and
the pinctrl->groups[] array is the same way.  These are set in
ns2_pinmux_probe().  So the > comparisons should be >= so that we don't
read one element beyond the end of the array.

Fixes: b5aa1006 ("pinctrl: ns2: add pinmux driver support for Broadcom NS2 SoC")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190926081426.GB2332@mwandaAcked-by: default avatarScott Branden <scott.branden@broadcom.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent f876dbff
...@@ -640,8 +640,8 @@ static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev, ...@@ -640,8 +640,8 @@ static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev,
const struct ns2_pin_function *func; const struct ns2_pin_function *func;
const struct ns2_pin_group *grp; const struct ns2_pin_group *grp;
if (grp_select > pinctrl->num_groups || if (grp_select >= pinctrl->num_groups ||
func_select > pinctrl->num_functions) func_select >= pinctrl->num_functions)
return -EINVAL; return -EINVAL;
func = &pinctrl->functions[func_select]; func = &pinctrl->functions[func_select];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment