From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 2/3] tty: serial: imx: Propagate errors from optional IRQ lookup
Date: Fri, 07 Aug 2026 09:18:45 +0000 [thread overview]
Message-ID: <20260807091846.2CCA01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807090945.41690-2-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The global `imx_uart_ports` array retains a dangling pointer to a freed `sport` object if `uart_add_one_port()` fails during probe, or after device unbind.
--
--- Patch [2]: [PATCH 2/3] tty: serial: imx: Propagate errors from optional IRQ lookup ---
commit 1b33dc8f639bc337c3928860fbfd0de822e373c4
Author: bui duc phuc <phucduc.bui@gmail.com>
tty: serial: imx: Propagate errors from optional IRQ lookup
This commit updates imx_uart_probe() to properly propagate error codes
from platform_get_irq_optional(). It ensures that errors like probe
deferrals are returned rather than ignored.
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 251a50c8aa387..4224454d360ef 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2463,7 +2463,11 @@ static int imx_uart_probe(struct platform_device *pdev)
> if (rxirq < 0)
> return rxirq;
> txirq = platform_get_irq_optional(pdev, 1);
> + if (txirq < 0 && txirq != -ENXIO)
> + return txirq;
> rtsirq = platform_get_irq_optional(pdev, 2);
> + if (rtsirq < 0 && rtsirq != -ENXIO)
> + return rtsirq;
>
> sport->port.dev = &pdev->dev;
> sport->port.mapbase = res->start;
[Severity: High]
This is a pre-existing issue, but looking further down in imx_uart_probe(),
does the error path for uart_add_one_port() leave a dangling pointer in the
global array?
If uart_add_one_port() fails, we see this sequence:
drivers/tty/serial/imx.c:imx_uart_probe() {
...
imx_uart_ports[sport->port.line] = sport;
...
ret = uart_add_one_port(&imx_uart_uart_driver, &sport->port);
err_clk:
clk_disable_unprepare(sport->clk_ipg);
return ret;
}
When this returns an error, devres will free the memory for sport, but
the global imx_uart_ports array still retains the pointer. Can a subsequent
console operation dereference this freed memory?
Additionally, the same issue appears to exist in imx_uart_remove() when
the device is unbound:
drivers/tty/serial/imx.c:imx_uart_remove() {
struct imx_port *sport = platform_get_drvdata(pdev);
uart_remove_one_port(&imx_uart_uart_driver, &sport->port);
}
Should this removal function explicitly clear the pointer from
imx_uart_ports to avoid leaving a dangling pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807090945.41690-1-phucduc.bui@gmail.com?part=2
next prev parent reply other threads:[~2026-08-07 9:18 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 [this message]
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
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=20260807091846.2CCA01F000E9@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 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.