From: geert+renesas@glider.be (Geert Uytterhoeven)
To: linux-snps-arc@lists.infradead.org
Subject: [PATCH v2 4/9] serial: mxs-auart: Fix out-of-bounds access through serial port index
Date: Fri, 23 Feb 2018 14:38:32 +0100 [thread overview]
Message-ID: <1519393117-31998-5-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1519393117-31998-1-git-send-email-geert+renesas@glider.be>
The auart_port[] array is indexed using a value derived from the
"serialN" alias in DT, or from platform data, which may lead to an
out-of-bounds access.
Fix this by adding a range check.
Fixes: 1ea6607d4cdc9179 ("serial: mxs-auart: Allow device tree probing")
Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
---
v2:
- Fix Fixes reference,
- Use ARRAY_SIZE(),
- Update patch description for platform data.
---
drivers/tty/serial/mxs-auart.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 079dc47aa142d8e1..caa8a41b6e71df9e 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1663,6 +1663,10 @@ static int mxs_auart_probe(struct platform_device *pdev)
s->port.line = pdev->id < 0 ? 0 : pdev->id;
else if (ret < 0)
return ret;
+ if (s->port.line >= ARRAY_SIZE(auart_port)) {
+ dev_err(&pdev->dev, "serial%d out of range\n", s->port.line);
+ return -EINVAL;
+ }
if (of_id) {
pdev->id_entry = of_id->data;
--
2.7.4
next prev parent reply other threads:[~2018-02-23 13:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 13:38 [PATCH v2 0/9] serial: Fix out-of-bounds accesses through DT aliases Geert Uytterhoeven
2018-02-23 13:38 ` Geert Uytterhoeven [this message]
2018-02-23 13:38 ` [PATCH v2 7/9] serial: sh-sci: Fix out-of-bounds access through DT alias Geert Uytterhoeven
[not found] ` <1519393117-31998-10-git-send-email-geert+renesas@glider.be>
2018-02-23 13:41 ` [PATCH v2 9/9] serial: xuartps: " Michal Simek
[not found] ` <1519393117-31998-4-git-send-email-geert+renesas@glider.be>
2018-02-23 13:51 ` [PATCH v2 3/9] serial: imx: Fix out-of-bounds access through serial port index Uwe Kleine-König
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=1519393117-31998-5-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=linux-snps-arc@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).