diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-02-24 12:32:50 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-03-06 22:28:05 -0500 |
commit | 5e9a207547079a23c3d4ecb4bad050ba8acc3f59 (patch) | |
tree | 5863e547ca63d319385f351b0c5d134d85f05826 | |
parent | 35cec70720db028bfd18d739fd3df65f21c34590 (diff) |
pinctrl: lpc18xx: ensure ngroups is initialized at correct place
The initialization of ngroups is occurring at the end of the
first iteration of the outer loop, which means that the
assignment pins[ngroups++] = i is potentially indexing into
a region outside of array pins because ngroups is not initialized.
Instead, initialize ngroups in the inner loop before the first
inner loop iteration.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-lpc18xx.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-lpc18xx.c b/drivers/pinctrl/pinctrl-lpc18xx.c index f0bebbe0682b..ed1cfa7e43dd 100644 --- a/drivers/pinctrl/pinctrl-lpc18xx.c +++ b/drivers/pinctrl/pinctrl-lpc18xx.c | |||
@@ -1170,9 +1170,8 @@ static int lpc18xx_create_group_func_map(struct device *dev, | |||
1170 | u16 pins[ARRAY_SIZE(lpc18xx_pins)]; | 1170 | u16 pins[ARRAY_SIZE(lpc18xx_pins)]; |
1171 | int func, ngroups, i; | 1171 | int func, ngroups, i; |
1172 | 1172 | ||
1173 | for (func = 0; func < FUNC_MAX; ngroups = 0, func++) { | 1173 | for (func = 0; func < FUNC_MAX; func++) { |
1174 | 1174 | for (ngroups = 0, i = 0; i < ARRAY_SIZE(lpc18xx_pins); i++) { | |
1175 | for (i = 0; i < ARRAY_SIZE(lpc18xx_pins); i++) { | ||
1176 | if (lpc18xx_valid_pin_function(i, func)) | 1175 | if (lpc18xx_valid_pin_function(i, func)) |
1177 | pins[ngroups++] = i; | 1176 | pins[ngroups++] = i; |
1178 | } | 1177 | } |