pinctrl: nsp: off by ones in nsp_pinmux_enable()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 3 Jul 2018 12:04:25 +0000 (15:04 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 14 Jul 2018 10:47:04 +0000 (12:47 +0200)
The > comparisons should be >= or else we read beyond the end of the
pinctrl->functions[] array.

Fixes: cc4fa83f66e9 ("pinctrl: nsp: add pinmux driver support for Broadcom NSP SoC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/bcm/pinctrl-nsp-mux.c

index 35c17653c694767c8e13d1a8d02d7d91718d23b3..5cd8166fbbc80dd1fb3f25bd4ef018e1404799eb 100644 (file)
@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
        const struct nsp_pin_function *func;
        const struct nsp_pin_group *grp;
 
-       if (grp_select > pinctrl->num_groups ||
-               func_select > pinctrl->num_functions)
+       if (grp_select >= pinctrl->num_groups ||
+           func_select >= pinctrl->num_functions)
                return -EINVAL;
 
        func = &pinctrl->functions[func_select];