From: sashiko-bot@kernel.org
To: "Shawn Lin" <shawn.lin@rock-chips.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/2] PCI: dw-rockchip: Bail out if the INTx irq domain creation fails
Date: Thu, 03 Sep 2026 03:12:09 +0000 [thread overview]
Message-ID: <20260903031209.B655A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <1788403477-71491-2-git-send-email-shawn.lin@rock-chips.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a missing IRQ domain and chained handler cleanup on initialization failure paths, leading to a memory leak and potential Use-After-Free.
- [High] This problem wasn't introduced by this patch, but there is an unprotected lockless iteration over the PCI bus devices list in the threaded IRQ handler.
--
commit e7543706c2d1058d78b54feb3252321efa4a390b
Author: Shawn Lin <shawn.lin@rock-chips.com>
PCI: dw-rockchip: Bail out if the INTx irq domain creation fails
rockchip_pcie_init_irq_domain() can fail, e.g. when the DT node is
missing its "legacy-interrupt-controller" child node. This commit
propagates the error to abort probing instead of continuing with a
NULL irq_domain, which previously caused a panic on the first INTx.
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index af26a07c0c9e5..50824c8b1d83e 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -432,8 +432,10 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
> pci->dbi_base2 = pci->dbi_base + PCIE_TYPE0_HDR_DBI2_OFFSET;
>
> ret = rockchip_pcie_init_irq_domain(rockchip);
> - if (ret < 0)
> + if (ret < 0) {
> dev_err(dev, "failed to init irq domain\n");
> + return ret;
> + }
>
> irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
> rockchip);
[Severity: High]
This is a pre-existing regression, but there is a missing IRQ
domain and chained handler cleanup on initialization failure paths,
which can cause a memory leak and use-after-free.
If rockchip_pcie_host_init() succeeds but a subsequent step in
dw_pcie_host_init() fails (e.g., link training), the probe aborts and
devres frees the rockchip struct. Because the driver lacks a .deinit
callback in rockchip_pcie_host_ops, the IRQ domain allocated via
irq_domain_create_linear() is leaked.
Additionally, the chained handler mapped via
irq_set_chained_handler_and_data() is never removed. Can a subsequent
legacy interrupt or spurious trigger invoke rockchip_pcie_intx_handler()
with the devm-freed rockchip pointer, causing a kernel panic?
Does rockchip_pcie_host_ops need a .deinit callback to properly unwind
these resources on failure paths?
While reviewing this file, another pre-existing regression was noticed in
rockchip_pcie_rc_sys_irq_thread():
drivers/pci/controller/dwc/pcie-dw-rockchip.c:rockchip_pcie_rc_sys_irq_thread() {
[ ... ]
if (reg & PCIE_LINK_REQ_RST_NOT_INT) {
dev_dbg(dev, "hot reset or link-down reset\n");
for_each_pci_bridge(port, pp->bridge->bus) {
if (pci_pcie_type(port) == PCI_EXP_TYPE_ROOT_PORT)
pci_host_handle_link_down(port);
}
}
[ ... ]
}
[Severity: High]
This is a pre-existing regression, but there is an unprotected lockless
iteration over the PCI bus devices list in this threaded IRQ handler.
When a hot-reset or link-down event occurs, the handler traverses
pp->bridge->bus->devices using for_each_pci_bridge(). This traversal is
performed locklessly without acquiring the required down_read(&pci_bus_sem).
If a concurrent PCI device removal operation modifies the list (e.g., via
sysfs or hotplug), could this lockless traversal access poisoned pointers
or freed device structures, potentially causing list corruption or a panic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/1788403477-71491-1-git-send-email-shawn.lin@rock-chips.com?part=1
next prev parent reply other threads:[~2026-09-03 3:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 2:44 [PATCH 0/2] Two small INTx fixes for Rockchip's dwc based PCIe controller driver Shawn Lin
2026-09-03 2:44 ` [PATCH 1/2] PCI: dw-rockchip: Bail out if the INTx irq domain creation fails Shawn Lin
2026-09-03 3:12 ` sashiko-bot [this message]
2026-09-03 3:42 ` Shawn Lin
2026-09-03 2:44 ` [PATCH 2/2] PCI: dw-rockchip: Do not recreate the INTx irq domain on root port reset Shawn Lin
2026-09-03 3:13 ` sashiko-bot
2026-09-03 3:46 ` Shawn Lin
2026-09-03 8:37 ` Niklas Cassel
2026-09-03 10:02 ` Shawn Lin
2026-09-03 8:20 ` [PATCH 0/2] Two small INTx fixes for Rockchip's dwc based PCIe controller driver Niklas Cassel
2026-09-03 8:26 ` Shawn Lin
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=20260903031209.B655A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shawn.lin@rock-chips.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox