From: sashiko-bot@kernel.org
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port
Date: Wed, 14 Oct 2026 06:49:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-170897@kernel.org> (raw)
In-Reply-To: <c59fa203f325e0fe7601ea0fbc0d222c8b37f9eb.1791873876.git.jirislaby@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tty: serial: 8250_hp300: NULL pointer dereference on hpdca device removal
--
commit f913317bfee3afed5e144530ca60f25858464754
Author: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Date: Tue Oct 13 06:48:51 2026 +0000
serial: 8250: make port operations work on struct uart_8250_port
This commit switches the interface of port operations to use
struct uart_8250_port instead of the line number, returning the registered
port or an ERR_PTR() on failure. It updates all drivers to store the port
pointer instead of the line number.
> diff --git a/drivers/tty/serial/8250/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
> index 59ec0c7377a1c..e9599c5c2fead 100644
> --- a/drivers/tty/serial/8250/8250_hp300.c
> +++ b/drivers/tty/serial/8250/8250_hp300.c
[ ... ]
> @@ -177,9 +177,8 @@ static int hpdca_init_one(struct dio_dev *d,
> uart.port.membase = (char *)(uart.port.mapbase + DIO_VIRADDRBASE);
> uart.port.regshift = 1;
> uart.port.dev = &d->dev;
> - line = serial8250_register_8250_port(&uart);
> -
> - if (line < 0) {
> + uport = serial8250_register_8250_port(&uart);
> + if (IS_ERR(uport)) {
> dev_notice(&d->dev,
> "8250_hp300: register_serial() DCA scode %d irq %d failed\n",
> d->scode, uart.port.irq);
> return 0;
> }
>
> /* Enable board-interrupts */
> out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, DCA_IC_IE);
> - dio_set_drvdata(d, (void *)line);
> + dio_set_drvdata(d, uport);
>
> /* Reset the DCA */
> out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
[Severity: High]
If serial8250_register_8250_port() fails here and returns an ERR_PTR, this
function logs a warning and returns 0 (success). In this failure path,
dio_set_drvdata() is skipped, leaving the device's driver data as NULL.
Because the driver returns 0, the device is considered successfully bound.
When the device is later removed, hpdca_remove_one() is called:
> @@ -287,14 +283,13 @@ static int __init hp300_8250_init(void)
> #ifdef CONFIG_HPDCA
> static void hpdca_remove_one(struct dio_dev *d)
> {
> - int line;
> + struct uart_8250_port *uport = dio_get_drvdata(d);
>
> - line = (int) dio_get_drvdata(d);
> if (d->resource.start) {
> /* Disable board-interrupts */
> out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0);
> }
> - serial8250_unregister_port(line);
> + serial8250_unregister_port(uport);
> }
> #endif
Will this lead to a NULL pointer dereference?
If the registration failed during probe, uport will be NULL here. Since
serial8250_unregister_port() unconditionally dereferences the pointer (e.g.,
checking uart->em485), passing NULL will cause a kernel panic.
Should the failure path in hpdca_init_one() return an error code instead of
0, or should hpdca_remove_one() check for a valid uport before
unregistering?
Note: This replaces a prior bug where passing an uninitialized 0 line number
caused the driver to erroneously unregister ttyS0 instead of crashing.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791873876.git.jirislaby@kernel.org?part=6
prev parent reply other threads:[~2026-10-14 6:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 6:48 [PATCH v2 0/6] serial: 8250: make port operations work on struct uart_8250_port Jiri Slaby (SUSE)
2026-10-13 6:48 ` [PATCH v2 1/6] serial: 8250: drop err label from serial8250_register_8250_port() Jiri Slaby (SUSE)
2026-10-14 6:49 ` sashiko-bot
2026-10-13 6:48 ` [PATCH v2 2/6] serial: 8250_exar: remove useless void * casts Jiri Slaby (SUSE)
2026-10-14 6:49 ` sashiko-bot
2026-10-13 6:48 ` [PATCH v2 3/6] serial: 8250_exar: store the GPIO platform device in struct exar8250 Jiri Slaby (SUSE)
2026-10-14 6:49 ` sashiko-bot
2026-10-13 6:48 ` [PATCH v2 4/6] serial: 8250_lpss: do not touch uninitialized line in ehl_serial_exit() Jiri Slaby (SUSE)
2026-10-13 21:13 ` Andy Shevchenko
2026-10-14 6:49 ` sashiko-bot
2026-10-13 6:48 ` [PATCH v2 5/6] serial: 8250_omap: set priv->line before enabling the IRQ Jiri Slaby (SUSE)
2026-10-14 6:49 ` sashiko-bot
2026-10-13 6:48 ` [PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port Jiri Slaby (SUSE)
2026-10-13 7:33 ` Andy Shevchenko
2026-10-13 7:53 ` Jiri Slaby
2026-10-13 9:09 ` Andy Shevchenko
2026-10-13 9:39 ` Jiri Slaby
2026-10-13 10:00 ` Andy Shevchenko
2026-10-13 10:15 ` Jiri Slaby
2026-10-13 10:54 ` Alejandro Colomar
2026-10-13 10:51 ` Alejandro Colomar
2026-10-13 11:06 ` Jiri Slaby
2026-10-13 13:42 ` Andy Shevchenko
2026-10-14 6:49 ` sashiko-bot [this message]
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=sashiko-outbox-170897@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jirislaby@kernel.org \
--cc=linux-serial@vger.kernel.org \
--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.