From: Tony Lindgren <tony@atomide.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-kernel@vger.kernel.org, Peter Ujfalusi <peter.ujfalusi@ti.com>
Subject: Re: [PATCH 3/3] pinctrl: single: fix infinite loop caused by bad mask
Date: Sat, 30 Nov 2013 09:21:48 -0800 [thread overview]
Message-ID: <20131130172147.GC23334@atomide.com> (raw)
In-Reply-To: <1385638160-30125-3-git-send-email-tomi.valkeinen@ti.com>
* Tomi Valkeinen <tomi.valkeinen@ti.com> [131128 03:30]:
> 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.
Linus W, might be worth updating the change log with the regression
causing commit. Something like 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.
Acked-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
> drivers/pinctrl/pinctrl-single.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> 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,
> mask_pos = ((pcs->fmask) << (bit_pos - 1));
> val_pos = val & mask_pos;
> submask = mask & mask_pos;
> +
> + if ((mask & mask_pos) == 0) {
> + dev_err(pcs->dev,
> + "Invalid mask for %s at 0x%x\n",
> + np->name, offset);
> + break;
> + }
> +
> mask &= ~mask_pos;
>
> if (submask != mask_pos) {
> --
> 1.8.3.2
>
next prev parent reply other threads:[~2013-11-30 17:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 11:29 [PATCH 1/3] pinctrl: single: fix DT bindings documentation Tomi Valkeinen
2013-11-28 11:29 ` [PATCH 2/3] pinctrl: single: fix pcs_disable with bits_per_mux Tomi Valkeinen
2013-11-28 12:00 ` Peter Ujfalusi
2013-11-30 17:07 ` Tony Lindgren
2013-11-30 17:24 ` Tony Lindgren
2013-11-28 11:29 ` [PATCH 3/3] pinctrl: single: fix infinite loop caused by bad mask Tomi Valkeinen
2013-11-30 17:21 ` Tony Lindgren [this message]
2013-11-30 17:05 ` [PATCH 1/3] pinctrl: single: fix DT bindings documentation Tony Lindgren
-- strict thread matches above, loose matches on Subject: below --
2014-01-09 12:50 Tomi Valkeinen
2014-01-09 12:50 ` [PATCH 3/3] pinctrl: single: fix infinite loop caused by bad mask Tomi Valkeinen
2014-01-15 7:32 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131130172147.GC23334@atomide.com \
--to=tony@atomide.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox