All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: apple: Release port IRQs and domains on driver detach
Date: Thu, 26 Nov 2026 08:42:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-235048@kernel.org> (raw)
In-Reply-To: <20261126-a35bb25eb5-u39-0@mail.sdu.edu.cn>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] PCI: apple: missing IS_ERR() check for port->phy in
  apple_pcie_setup_port() [1]
--

commit 102d3679b8d5966284cf3435e5c387deb0e77c02
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>

PCI: apple: Release port IRQs and domains on driver detach

This commit registers device-managed cleanup actions for the per-port
interrupt domains, link IRQs, and the MSI parent domain, and wires up
pci_host_common_remove() on driver detach.

> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index dfd0e345bc567..79dac3fb9a05c 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
[ ... ]
> @@ -582,6 +602,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  	port->idx = idx >> 11;
>  	port->pcie = pcie;
>  	port->np = np;
> +	INIT_LIST_HEAD(&port->entry);
>  
>  	raw_spin_lock_init(&port->lock);

[Severity: High]
This problem wasn't introduced by this patch, but can
apple_pcie_setup_port() [1] dereference an error pointer in
port->phy when devm_ioremap_resource() fails?

Later in apple_pcie_setup_port(), port->phy is mapped without an IS_ERR()
check and then passed to apple_pcie_setup_refclk() for MMIO access:

drivers/pci/controller/pcie-apple.c:apple_pcie_setup_port() {
	...
	snprintf(name, sizeof(name), "phy%d", port->idx);
	res = platform_get_resource_byname(platform, IORESOURCE_MEM, name);
	if (res)
		port->phy = devm_ioremap_resource(&platform->dev, res);
	else
		port->phy = pcie->base + CORE_PHY_DEFAULT_BASE(port->idx);

	rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);

	/* Assert PERST# before setting up the clock */
	gpiod_set_value_cansleep(reset, 1);

	ret = apple_pcie_setup_refclk(pcie, port);
	...
}

If mapping the named PHY resource fails, rmw_set() in
apple_pcie_setup_refclk() will dereference the ERR_PTR() value in
port->phy and crash during probe.

[1] https://sashiko.dev/#/bug/linux-7340dc46-b98f-4a1f-909a-9ae73ed0ddc9

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-a35bb25eb5-u39-0@mail.sdu.edu.cn?part=1

      reply	other threads:[~2026-11-26  8:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:28 [PATCH] PCI: apple: Release port IRQs and domains on driver detach Guangshuo Li
2026-11-26  8:42 ` sashiko-bot [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=sashiko-outbox-235048@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=liguangshuo@mail.sdu.edu.cn \
    --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 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.