pinctrl: tegra: Fix off by one in tegra_pinctrl_get_group()

commit 5a062c3c3b82004766bc3ece82b594d337076152 upstream.

This should be >= pmx->soc->ngroups instead of > to avoid an out of
bounds access.  The pmx->soc->groups[] array is allocated in
tegra_pinctrl_probe().

Fixes: c12bfa0fee65 ("pinctrl-tegra: Restore SFSEL bit when freeing pins")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Kunwu Chan <kunwu.chan@linux.dev>
Link: https://lore.kernel.org/82b40d9d-b437-42a9-9eb3-2328aa6877ac@stanley.mountain
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dan Carpenter
2025-03-19 10:05:47 +03:00
committed by Greg Kroah-Hartman
parent 4a5e6e798e
commit 1f91707374

View File

@@ -307,7 +307,7 @@ static const struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *
{ {
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
if (group_index < 0 || group_index > pmx->soc->ngroups) if (group_index < 0 || group_index >= pmx->soc->ngroups)
return NULL; return NULL;
return &pmx->soc->groups[group_index]; return &pmx->soc->groups[group_index];