From: sashiko-bot@kernel.org
To: "Grégoire Layet" <gregoire.layet@9elements.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v4 4/7] serial: 8250_aspeed_vuart: add VUART over PCI
Date: Wed, 08 Jul 2026 15:47:35 +0000 [thread overview]
Message-ID: <20260708154735.D55C81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <28c6e7c493559feffc7e6231b0a2f0b73b7fda41.1783524645.git.gregoire.layet@9elements.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Probe error paths fail to unregister the 8250 serial port and cancel the unthrottle timer, causing a resource leak and potential use-after-free.
- [High] Sysfs attributes are exposed before the driver data is set, creating a race window that leads to a NULL pointer dereference.
--
--- Patch [4]: [PATCH v4 4/7] serial: 8250_aspeed_vuart: add VUART over PCI ---
commit d4ec19577207abb14c5ca6354d48ef6da9508b14
Author: Grégoire Layet <gregoire.layet@9elements.com>
serial: 8250_aspeed_vuart: add VUART over PCI
Enable the VUART over PCI for the AST2600. Activate it only if the
'aspeed,vuart-over-pci' property flag is set on an 'ast2600-vuart'
compatible node.
> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 6afa2f4057e1b..4d09c04cb9727 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
[ ... ]
> @@ -540,6 +617,15 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
> aspeed_vuart_set_host_tx_discard(vuart, true);
> platform_set_drvdata(pdev, vuart);
[Severity: High]
This is a pre-existing issue, but setting the driver data this late creates a
race condition.
The sysfs attribute group is created earlier in aspeed_vuart_probe():
rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
If userspace accesses these sysfs files (e.g., triggering sirq_show()) before
platform_set_drvdata() is called here, dev_get_drvdata() returns NULL, which
then leads to a NULL pointer dereference.
Could the sysfs creation be deferred until after the driver data is set?
>
> + if (of_device_is_compatible(dev->of_node, "aspeed,ast2600-vuart") &&
> + of_property_read_bool(dev->of_node, "aspeed,vuart-over-pci")) {
> + rc = aspeed_ast2600_vuart_over_pci_set_enabled(pdev);
> + if (rc < 0) {
> + dev_err_probe(dev, rc, "could not enable VUART over PCI\n");
> + goto err_sysfs_remove;
[Severity: High]
This is a pre-existing issue, but this error path fails to unregister the 8250
serial port and cancel the unthrottle timer.
If aspeed_ast2600_vuart_over_pci_set_enabled() fails, we jump to
err_sysfs_remove:
err_sysfs_remove:
sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
return rc;
}
This cleans up the sysfs group but leaves the serial port registered.
Since the vuart structure is allocated with devm_kzalloc, it will be freed
automatically by devres when the probe fails. This leaves a dangling pointer
in the active 8250 serial port's private data, which can result in a
use-after-free if the TTY device is accessed.
Should this error path also call serial8250_unregister_port() and
timer_delete_sync() before returning?
> + }
> + }
> +
> return 0;
>
> err_sysfs_remove:
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783524645.git.gregoire.layet@9elements.com?part=4
next prev parent reply other threads:[~2026-07-08 15:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 15:35 [PATCH v4 0/7] soc: aspeed: Add BMC and host driver for PCIe BMC device Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 1/7] dt-bindings: serial: 8250: aspeed: add compatible string for ast2600 Grégoire Layet
2026-07-08 16:38 ` Andrew Lunn
2026-07-09 8:50 ` Krzysztof Kozlowski
2026-07-09 14:21 ` Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 2/7] dt-bindings: serial: 8250: aspeed: add aspeed,vuart-over-pci bool prop Grégoire Layet
2026-07-08 15:45 ` sashiko-bot
2026-07-09 8:54 ` Krzysztof Kozlowski
2026-07-14 7:14 ` Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 3/7] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string Grégoire Layet
2026-07-08 15:49 ` sashiko-bot
2026-07-08 15:35 ` [PATCH v4 4/7] serial: 8250_aspeed_vuart: add VUART over PCI Grégoire Layet
2026-07-08 15:47 ` sashiko-bot [this message]
2026-07-08 16:46 ` Andrew Lunn
2026-07-09 5:18 ` Jiri Slaby
2026-07-14 6:36 ` Grégoire Layet
2026-07-09 5:17 ` Jiri Slaby
2026-07-14 6:33 ` Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 5/7] soc: aspeed: add host-side PCIe BMC device driver Grégoire Layet
2026-07-08 15:48 ` sashiko-bot
2026-07-09 5:27 ` Jiri Slaby
2026-07-14 6:46 ` Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 6/7] ARM: dts: aspeed: g6: Change vuart compatible string for ast2600 Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 7/7] ARM: dts: aspeed: g6: add aspeed,vuart-over-pci prop to vuart3 and 4 Grégoire Layet
2026-07-08 15: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=20260708154735.D55C81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregoire.layet@9elements.com \
--cc=robh@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.