From: sashiko-bot@kernel.org
To: "Pan Chuang" <panchuang@vivo.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 2/5] serial: imx: Remove redundant dev_err()
Date: Wed, 22 Jul 2026 03:57:31 +0000 [thread overview]
Message-ID: <20260722035731.8CDDE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722034342.316755-3-panchuang@vivo.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The global `imx_uart_ports` array retains a dangling pointer to a freed `sport` structure if `uart_add_one_port()` fails or when the driver is unbound.
- [High] The hrtimers `trigger_start_tx` and `trigger_stop_tx` are never synchronously cancelled during device teardown, leading to a potential Use-After-Free.
--
--- Patch [2]: [PATCH 2/5] serial: imx: Remove redundant dev_err() ---
commit 44174bba1c656c63bfedf3dc6b8ca0b3fa1165cb
Author: Pan Chuang <panchuang@vivo.com>
serial: imx: Remove redundant dev_err()
This commit removes driver-specific dev_err() calls after devm_request_irq(),
as the core function already logs detailed error messages on failure since
commit 55b48e23f5c4.
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 251a50c8aa387..95fdb60e06a77 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2602,34 +2602,23 @@ static int imx_uart_probe(struct platform_device *pdev)
[ ... ]
> } else {
> ret = devm_request_irq(&pdev->dev, rxirq, imx_uart_int, 0,
> dev_name(&pdev->dev), sport);
> - if (ret) {
> - dev_err(&pdev->dev, "failed to request irq: %d\n", ret);
> + if (ret)
> goto err_clk;
> - }
> }
>
> imx_uart_ports[sport->port.line] = sport;
[Severity: High]
This is a pre-existing issue, but does this leave a dangling pointer in
the global array if uart_add_one_port() fails later in the probe function?
If uart_add_one_port() fails, the function returns an error and devm
automatically frees the sport structure. However, the pointer was already
assigned to imx_uart_ports[sport->port.line] and is never cleared on the
error path. Could this lead to a use-after-free if the console subsystem or
sysrq accesses the array?
Similarly, it looks like imx_uart_remove() does not clear this array entry
before devres frees the memory during driver unbind.
[Severity: High]
This is also a pre-existing issue, but are the trigger_start_tx and
trigger_stop_tx hrtimers synchronously cancelled during device teardown?
Looking at the unbind path in imx_uart_remove():
static void imx_uart_remove(struct platform_device *pdev)
{
struct imx_port *sport = platform_get_drvdata(pdev);
uart_remove_one_port(&imx_uart_uart_driver, &sport->port);
}
During unbind, imx_uart_shutdown() tries to stop the port and calls
hrtimer_try_to_cancel() implicitly. However, hrtimer_try_to_cancel() doesn't
wait for a currently executing callback to finish.
Since explicit hrtimer_cancel() is never called in imx_uart_remove(),
could devres free the sport structure while the hrtimer callback is still
running or pending on another CPU, resulting in a use-after-free?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722034342.316755-1-panchuang@vivo.com?part=2
next prev parent reply other threads:[~2026-07-22 3:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 3:43 [PATCH 0/5] serial: Remove redundant error messages on IRQ request failure Pan Chuang
2026-07-22 3:43 ` [PATCH 1/5] serial: 8250_bcm7271: Remove redundant dev_err_probe() Pan Chuang
2026-07-22 3:43 ` [PATCH 2/5] serial: imx: Remove redundant dev_err() Pan Chuang
2026-07-22 3:57 ` sashiko-bot [this message]
2026-07-22 3:43 ` [PATCH 3/5] serial: mvebu-uart: " Pan Chuang
2026-07-22 3:43 ` [PATCH 4/5] serial: mctrl_gpio: " Pan Chuang
2026-07-22 3:43 ` [PATCH 5/5] serial: sprd: " Pan Chuang
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=20260722035731.8CDDE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=panchuang@vivo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.