aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2014-01-09 07:50:29 -0500
committerLinus Walleij <linus.walleij@linaro.org>2014-01-15 02:31:53 -0500
commitad5d25fef8f9459a9f67ec5fbae94287fdea3247 (patch)
treecde8521539c7cb408ffb7c0c7eb5a47c3ec1532b /drivers/pinctrl
parentdd4c2b3cb39da587fc1e5a9315d4d894a83ec481 (diff)
pinctrl: single: fix infinite loop caused by bad mask
commit 4e7e8017a80e1 (pinctrl: pinctrl-single: enhance to configure multiple pins of different modules) improved support for pinctrl-single,bits option, but also caused a regression in parsing badly configured mask data. If the masks in DT data are not quite right, pcs_parse_bits_in_pinctrl_entry() can end up in an infinite loop, trashing memory at the same time. Add a check to verify that each loop actually removes bits from the 'mask', so that the loop can eventually end. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-single.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 174f4c50cd77..de6459628b4f 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1318,6 +1318,14 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1318 mask_pos = ((pcs->fmask) << (bit_pos - 1)); 1318 mask_pos = ((pcs->fmask) << (bit_pos - 1));
1319 val_pos = val & mask_pos; 1319 val_pos = val & mask_pos;
1320 submask = mask & mask_pos; 1320 submask = mask & mask_pos;
1321
1322 if ((mask & mask_pos) == 0) {
1323 dev_err(pcs->dev,
1324 "Invalid mask for %s at 0x%x\n",
1325 np->name, offset);
1326 break;
1327 }
1328
1321 mask &= ~mask_pos; 1329 mask &= ~mask_pos;
1322 1330
1323 if (submask != mask_pos) { 1331 if (submask != mask_pos) {