From: Jia Wang <wangjia@ultrarisc.com>
To: sashiko-reviews@lists.linux.dev
Cc: Jia Wang <wangjia@ultrarisc.com>,
linux-pci@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 3/3] PCI: ultrarisc: allow DP1000 driver to build as module
Date: Tue, 07 Jul 2026 10:48:17 +0800 [thread overview]
Message-ID: <178339249750.3836076.2659050467958951262.b4-reply@b4> (raw)
In-Reply-To: <20260706100746.1673F1F000E9@smtp.kernel.org>
On 2026-07-06 10:07 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Missing `.remove` callback leaves the PCI root bus registered, causing a use-after-free on module unload.
> --
>
> commit 14ef8e08324f6393567996c3e1dc0b2cadbcfc0a
> Author: Jia Wang <wangjia@ultrarisc.com>
>
> PCI: ultrarisc: allow DP1000 driver to build as module
>
> This commit changes the driver registration from builtin_platform_driver()
> to module_platform_driver(). This allows the driver to be built and
> dynamically loaded or unloaded as a kernel module.
>
> > diff --git a/drivers/pci/controller/dwc/pcie-ultrarisc.c b/drivers/pci/controller/dwc/pcie-ultrarisc.c
> > --- a/drivers/pci/controller/dwc/pcie-ultrarisc.c
> > +++ b/drivers/pci/controller/dwc/pcie-ultrarisc.c
> > @@ -225,7 +225,7 @@ static struct platform_driver ultrarisc_pcie_driver = {
> > },
> > .probe = ultrarisc_pcie_probe,
> > };
> > -builtin_platform_driver(ultrarisc_pcie_driver);
> > +module_platform_driver(ultrarisc_pcie_driver);
>
> [Severity: High]
> By switching to module_platform_driver(), this driver can now be unloaded
> dynamically. However, since ultrarisc_pcie_driver lacks a .remove callback,
> will unloading the module leave the active PCI root bus, IRQ domains, and
> child devices registered?
>
> If devres automatically frees the struct ultrarisc_pcie memory and unmaps
> MMIO registers on module unload while the PCI subsystem still retains
> pointers to them, could this result in a use-after-free and kernel panic
> during subsequent PCI config space accesses?
>
Thanks for pointing this out.
The driver does support `CONFIG_PCIE_ULTRARISC=m`, so it should provide a
proper teardown path for module unload. I'll add a `.remove()` callback in
the next version to clean up the PCI host resources accordingly.
> >
> > MODULE_DESCRIPTION("UltraRISC DP1000 DWC PCIe host controller");
> > MODULE_LICENSE("GPL");
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260706-ultrarisc-pci-clk-v2-0-2f3fb6fba66b@ultrarisc.com?part=3
>
Best regards,
Jia Wang
prev parent reply other threads:[~2026-07-07 2:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:58 [PATCH v2 0/3] PCI: ultrarisc: Add DP1000 PCIe clock support Jia Wang via B4 Relay
2026-07-06 9:58 ` [PATCH v2 1/3] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay
2026-07-06 10:05 ` sashiko-bot
2026-07-06 9:58 ` [PATCH v2 2/3] PCI: ultrarisc: get and enable " Jia Wang via B4 Relay
2026-07-06 10:11 ` sashiko-bot
2026-07-06 9:58 ` [PATCH v2 3/3] PCI: ultrarisc: allow DP1000 driver to build as module Jia Wang via B4 Relay
2026-07-06 10:07 ` sashiko-bot
2026-07-07 2:48 ` Jia Wang [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=178339249750.3836076.2659050467958951262.b4-reply@b4 \
--to=wangjia@ultrarisc.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox