From: Henry Martin <bsdhenrymartin@gmail.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
sugaya.taichi@socionext.com, orito.takao@socionext.com,
u.kleine-koenig@baylibre.com
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Henry Martin <bsdhenrymartin@gmail.com>
Subject: [PATCH v1] serial: Fix null-ptr-deref in mlb_usio_probe()
Date: Thu, 3 Apr 2025 14:28:08 +0800 [thread overview]
Message-ID: <20250403062808.63428-1-bsdhenrymartin@gmail.com> (raw)
devm_ioremap() returns NULL on error. Currently, mlb_usio_probe() does
not check for this case, which results in a NULL pointer dereference.
Add NULL check after devm_ioremap() to prevent this issue.
Fixes: ba44dc043004 ("serial: Add Milbeaut serial control")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
drivers/tty/serial/milbeaut_usio.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/milbeaut_usio.c b/drivers/tty/serial/milbeaut_usio.c
index 059bea18dbab..4e47dca2c4ed 100644
--- a/drivers/tty/serial/milbeaut_usio.c
+++ b/drivers/tty/serial/milbeaut_usio.c
@@ -523,7 +523,10 @@ static int mlb_usio_probe(struct platform_device *pdev)
}
port->membase = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
-
+ if (!port->membase) {
+ ret = -ENOMEM;
+ goto failed;
+ }
ret = platform_get_irq_byname(pdev, "rx");
mlb_usio_irq[index][RX] = ret;
--
2.34.1
next reply other threads:[~2025-04-03 6:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 6:28 Henry Martin [this message]
2025-04-03 6:49 ` [PATCH v1] serial: Fix null-ptr-deref in mlb_usio_probe() Greg KH
2025-04-03 7:03 ` [PATCH v2] " Henry Martin
2025-04-03 8:50 ` Markus Elfring
2025-04-03 8:59 ` Greg Kroah-Hartman
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=20250403062808.63428-1-bsdhenrymartin@gmail.com \
--to=bsdhenrymartin@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=orito.takao@socionext.com \
--cc=sugaya.taichi@socionext.com \
--cc=u.kleine-koenig@baylibre.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