All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 3/6] serial: 8250_exar: store the GPIO platform device in struct exar8250
Date: Wed, 14 Oct 2026 06:49:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-170895@kernel.org> (raw)
In-Reply-To: <03a8b5c71614fc672fef1e55c083bda6c73b5bf3.1791873876.git.jirislaby@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tty: 8250_exar: missing IS_ERR check causes invalid pointer deref
--

commit 6cdc2bc96a13008a8cfba8cca844ee2bb25786e6
Author: Jiri Slaby (SUSE) <jirislaby@kernel.org>

serial: 8250_exar: store the GPIO platform device in struct exar8250

The GPIO platform device is now stored in struct exar8250::gpio instead of
port->port.private_data to fix an issue where port 0 might not exist on
unbind. The platform->register_gpio() and platform->unregister_gpio()
callbacks are updated to take priv as an argument.

Link: https://lore.kernel.org/all/sashiko-outbox-166269@kernel.org/

> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index ad2e5841fbf69..29b2a29ab6f37 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
[ ... ]
> @@ -1167,22 +1169,21 @@ static const struct software_node exar_gpio_node = {
>  	.properties = exar_gpio_properties,
>  };
>  
> -static int xr17v35x_register_gpio(struct pci_dev *pcidev, struct uart_8250_port *port)
> +static int xr17v35x_register_gpio(struct exar8250 *priv, struct pci_dev *pcidev,
> +				  struct uart_8250_port *port)
>  {
>  	if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
> -		port->port.private_data =
> -			__xr17v35x_register_gpio(pcidev, &exar_gpio_node);
> +		priv->gpio = __xr17v35x_register_gpio(pcidev, &exar_gpio_node);

[Severity: High]
Does __xr17v35x_register_gpio() return an ERR_PTR if
platform_device_register_full() fails?

If it does, we might be storing an error pointer directly into priv->gpio in
xr17v35x_register_gpio() without validating it with IS_ERR(). Because the
error is ignored, the device probe successfully continues.

>  
>  	return 0;
>  }
>  
> -static void xr17v35x_unregister_gpio(struct uart_8250_port *port)
> +static void xr17v35x_unregister_gpio(struct exar8250 *priv)
>  {
> -	if (!port->port.private_data)
> -		return;
> -
> -	__xr17v35x_unregister_gpio(port->port.private_data);
> -	port->port.private_data = NULL;
> +	if (priv->gpio) {

[Severity: High]
Later, during module unload or device unbind, we evaluate if (priv->gpio)
here in xr17v35x_unregister_gpio().

Since an ERR_PTR is not NULL, the condition passes and the error pointer is
passed to __xr17v35x_unregister_gpio().

Inside, device_remove_software_node(&pdev->dev) attempts to dereference the
invalid pointer, resulting in a crash. Could we add an IS_ERR check when
assigning priv->gpio, or check for it here?

> +		__xr17v35x_unregister_gpio(priv->gpio);
> +		priv->gpio = NULL;
> +	}
>  }
[ ... ]
> @@ -1289,8 +1291,7 @@ static int iot2040_register_gpio(struct pci_dev *pcidev,
>  	writeb(IOT2040_UARTS_ENABLE, p + UART_EXAR_MPIOLVL_15_8);
>  	writeb(IOT2040_UARTS_GPIO_HI_MODE, p + UART_EXAR_MPIOSEL_15_8);
>  
> -	port->port.private_data =
> -		__xr17v35x_register_gpio(pcidev, &iot2040_gpio_node);
> +	priv->gpio = __xr17v35x_register_gpio(pcidev, &iot2040_gpio_node);

[Severity: High]
This looks like the same concern as above in xr17v35x_register_gpio(). If
__xr17v35x_register_gpio() fails and returns an error pointer, we'll store
it here in iot2040_register_gpio() unchecked.

>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791873876.git.jirislaby@kernel.org?part=3

  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 [this message]
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

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-170895@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.