From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 3/3] serial: 8250_mtk: Propagate errors from optional IRQ lookup
Date: Fri, 07 Aug 2026 09:22:44 +0000 [thread overview]
Message-ID: <20260807092245.4730E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807090945.41690-3-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] The probe function exits with an error without unregistering the previously registered 8250 port, leading to a port leak and a use-after-free of devm-allocated memory.
Pre-existing issues:
- [High] Runtime PM is enabled after the UART port is registered, violating TTY subsystem guidelines and risking circular wait conditions during probe.
--
--- Patch [3]: [PATCH 3/3] serial: 8250_mtk: Propagate errors from optional IRQ lookup ---
commit b5b9e4c48c3e7b1094e5e1c9834f9f8130a17c26
Author: bui duc phuc <phucduc.bui@gmail.com>
serial: 8250_mtk: Propagate errors from optional IRQ lookup
This commit updates mtk8250_probe() to propagate error codes such as
-EPROBE_DEFER or -EINVAL from platform_get_irq_optional(), rather than
continuing without an IRQ.
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index e6a56cf54ae0c..d0d2aecf90059 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
[ ... ]
> @@ -587,6 +587,8 @@ static int mtk8250_probe(struct platform_device *pdev)
> return data->line;
>
> data->rx_wakeup_irq = platform_get_irq_optional(pdev, 1);
> + if (data->rx_wakeup_irq < 0 && data->rx_wakeup_irq != -ENXIO)
> + return data->rx_wakeup_irq;
[Severity: Critical]
Does this error path leak the registered serial port?
The port was successfully registered earlier in mtk8250_probe() via
serial8250_register_8250_port(), but there is no call to
serial8250_unregister_port() before returning the error here.
Could this result in a use-after-free if the tty device is later accessed?
The devm-allocated memory for the data structure will be automatically freed
when the probe fails, but the port remains active globally.
>
> pm_runtime_set_active(&pdev->dev);
> pm_runtime_enable(&pdev->dev);
[Severity: High]
This is a pre-existing issue, but should runtime PM be enabled before
the serial port is registered?
The mtk8250_do_pm() callback invokes pm_runtime_get_sync(). If
serial8250_register_8250_port() synchronously invokes the pm callback
during registration, it will attempt to use uninitialized runtime PM
infrastructure, which can lead to circular wait conditions.
>
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807090945.41690-1-phucduc.bui@gmail.com?part=3
next prev parent reply other threads:[~2026-08-07 9:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 9:09 [PATCH 1/3] serial: qcom-geni: Propagate errors from optional IRQ lookup phucduc.bui
2026-08-07 9:09 ` [PATCH 2/3] tty: serial: imx: " phucduc.bui
2026-08-07 9:18 ` sashiko-bot
2026-08-08 9:57 ` Bui Duc Phuc
2026-08-07 9:09 ` [PATCH 3/3] serial: 8250_mtk: " phucduc.bui
2026-08-07 9:22 ` sashiko-bot [this message]
2026-08-08 10:42 ` Bui Duc Phuc
2026-08-07 9:17 ` [PATCH 1/3] serial: qcom-geni: " sashiko-bot
2026-08-08 9:41 ` Bui Duc Phuc
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=20260807092245.4730E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=phucduc.bui@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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