Commit 4ce504c4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Walleij

pinctrl: sprd: fix off by one bugs

info->groups[] has info->ngroups elements so these comparisons should be
>= instead of >.

Fixes: 41d32cfc ("pinctrl: sprd: Add Spreadtrum pin control driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarBaolin Wang <baolin.wang@spreadtrum.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 41470c37
...@@ -400,7 +400,7 @@ static int sprd_pmx_set_mux(struct pinctrl_dev *pctldev, ...@@ -400,7 +400,7 @@ static int sprd_pmx_set_mux(struct pinctrl_dev *pctldev,
unsigned long reg; unsigned long reg;
unsigned int val = 0; unsigned int val = 0;
if (group_selector > info->ngroups) if (group_selector >= info->ngroups)
return -EINVAL; return -EINVAL;
switch (func_selector) { switch (func_selector) {
...@@ -734,7 +734,7 @@ static int sprd_pinconf_group_get(struct pinctrl_dev *pctldev, ...@@ -734,7 +734,7 @@ static int sprd_pinconf_group_get(struct pinctrl_dev *pctldev,
struct sprd_pin_group *grp; struct sprd_pin_group *grp;
unsigned int pin_id; unsigned int pin_id;
if (selector > info->ngroups) if (selector >= info->ngroups)
return -EINVAL; return -EINVAL;
grp = &info->groups[selector]; grp = &info->groups[selector];
...@@ -753,7 +753,7 @@ static int sprd_pinconf_group_set(struct pinctrl_dev *pctldev, ...@@ -753,7 +753,7 @@ static int sprd_pinconf_group_set(struct pinctrl_dev *pctldev,
struct sprd_pin_group *grp; struct sprd_pin_group *grp;
int ret, i; int ret, i;
if (selector > info->ngroups) if (selector >= info->ngroups)
return -EINVAL; return -EINVAL;
grp = &info->groups[selector]; grp = &info->groups[selector];
...@@ -813,7 +813,7 @@ static void sprd_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, ...@@ -813,7 +813,7 @@ static void sprd_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,
const char *name; const char *name;
int i, ret; int i, ret;
if (selector > info->ngroups) if (selector >= info->ngroups)
return; return;
grp = &info->groups[selector]; grp = &info->groups[selector];
......
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