From: sashiko-bot@kernel.org
To: "Hans Zhang" <18255117159@163.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v7 3/3] PCI: cadence: Add LGA IP debugfs for LTSSM status
Date: Thu, 11 Jun 2026 17:35:19 +0000 [thread overview]
Message-ID: <20260611173519.D071B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611165933.20071-4-18255117159@163.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Invalid pointer derivation via `to_pci_epc()` in `cdns_pcie_ep_disable()` leading to a wild pointer dereference.
- [High] The `pcie-cadence-plat.c` driver incorrectly returns 0 on probe failure and lacks a `.remove` callback, leading to silent probe failures and severe use-after-free bugs on unbind.
--
commit b49dbfe29c305b407944a72dcdee68320ac08c7c
Author: Hans Zhang <18255117159@163.com>
PCI: cadence: Add LGA IP debugfs for LTSSM status
This commit extends debugfs support to LGA-based Cadence PCIe controllers.
The 'ltssm_status' file now supports both HPA and LGA IP by selecting the
appropriate register access based on the 'is_hpa' flag.
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> index c0e1194a936b3..370b19f4d38fb 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> @@ -655,6 +655,7 @@ void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep)
> struct device *dev = ep->pcie.dev;
> struct pci_epc *epc = to_pci_epc(dev);
[Severity: High]
This isn't a bug introduced by this patch, but can this lead to a wild pointer
dereference?
In cdns_pcie_ep_setup(), the epc object is allocated separately using
devm_pci_epc_create(), which embeds its own struct device (epc->dev).
Here in cdns_pcie_ep_disable(), the code attempts to recover the epc pointer
by passing the parent platform device (ep->pcie.dev) to to_pci_epc().
Because to_pci_epc() is a container_of macro, subtracting the offset of the
dev member from the platform device pointer will yield an invalid pointer.
Will dereferencing this pointer in downstream functions like
pci_epc_deinit_notify() cause memory corruption or a kernel panic during
driver unbind?
>
> + cdns_pcie_debugfs_deinit(&ep->pcie);
> pci_epc_deinit_notify(epc);
> pci_epc_mem_free_addr(epc, ep->irq_phys_addr, ep->irq_cpu_addr,
> SZ_128K);
[ ... ]
I also noticed a pre-existing issue in drivers/pci/controller/cadence/pcie-cadence-plat.c:
drivers/pci/controller/cadence/pcie-cadence-plat.c:cdns_plat_pcie_probe() {
...
err_init:
err_get_sync:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
cdns_pcie_disable_phy(cdns_plat_pcie->pcie);
phy_count = cdns_plat_pcie->pcie->phy_count;
while (phy_count--)
device_link_del(cdns_plat_pcie->pcie->link[phy_count]);
return 0;
}
[Severity: High]
This isn't a bug introduced by this patch, but does returning 0 here silently
mask probe failures from the driver core?
Also, the platform driver lacks a .remove callback:
static struct platform_driver cdns_plat_pcie_driver = {
.driver = {
.name = "cdns-pcie",
.of_match_table = cdns_plat_pcie_of_match,
.pm = &cdns_pcie_pm_ops,
},
.probe = cdns_plat_pcie_probe,
.shutdown = cdns_plat_pcie_shutdown,
};
Does the lack of a .remove callback mean no driver-specific teardown runs
on unbind?
Without it, devres will free the controller memory while leaving the active
PCI root bus and debugfs nodes with dangling pointers. Could this result in
use-after-free bugs when those pointers are accessed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611165933.20071-1-18255117159@163.com?part=3
next prev parent reply other threads:[~2026-06-11 17:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 16:59 [PATCH v7 0/3] PCI: cadence: Add LTSSM debugfs Hans Zhang
2026-06-11 16:59 ` [PATCH v7 1/3] PCI: cadence: Add HPA architecture flag Hans Zhang
2026-06-11 17:09 ` sashiko-bot
2026-06-11 16:59 ` [PATCH v7 2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status Hans Zhang
2026-06-11 17:22 ` sashiko-bot
2026-06-11 16:59 ` [PATCH v7 3/3] PCI: cadence: Add LGA " Hans Zhang
2026-06-11 17:35 ` sashiko-bot [this message]
2026-06-12 9:30 ` [PATCH v7 0/3] PCI: cadence: Add LTSSM debugfs Aksh Garg
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=20260611173519.D071B1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=18255117159@163.com \
--cc=linux-pci@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox