From: sashiko-bot@kernel.org
To: "Tarun Sahu" <tarunsahu@google.com>
Cc: linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v19 6/7] PCI: Enable async shutdown support
Date: Fri, 17 Jul 2026 02:56:33 +0000 [thread overview]
Message-ID: <20260717025634.0DBCA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716230411.2767394-7-tarunsahu@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a double-put bug in `pci_register_host_bridge()`'s error handling path when `device_register(&bus->dev)` fails, leading to a Use-After-Free and Double Free on the host bridge device.
--
--- Patch [6]: [PATCH v19 6/7] PCI: Enable async shutdown support ---
commit bf029d21ad5b4df727aa0c1ae7b24c789b0e433a
Author: David Jeffery <djeffery@redhat.com>
PCI: Enable async shutdown support
Like its async suspend support, allow PCI device shutdown to be performed
asynchronously to reduce shutdown time.
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index dd0abbc63e18d..af23814464060 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1046,6 +1046,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
>
> bus->bridge = get_device(&bridge->dev);
> device_enable_async_suspend(bus->bridge);
> + dev_set_async_shutdown(bus->bridge);
> pci_set_bus_of_node(bus);
> pci_set_bus_msi_domain(bus);
[Severity: High]
This problem wasn't introduced by this patch, but there appears to be a
pre-existing double-put bug in pci_register_host_bridge() when handling
registration failures.
Further down in pci_register_host_bridge(), if device_register(&bus->dev)
fails, the code jumps to the unregister label:
unregister:
put_device(&bridge->dev);
device_del(&bridge->dev);
free:
Does this path drop the caller's initial reference prematurely?
In the free block, because bus_registered is true, it calls
put_device(&bus->dev). The device's release function (release_pcibus_dev)
explicitly calls put_device(pci_bus->bridge), dropping the reference
correctly taken by bus->bridge = get_device(&bridge->dev).
Because the unregister block explicitly drops the caller's initial reference
early, the bridge is freed. The function then returns an error to the caller,
which will likely call put_device(&bridge->dev) to clean up its initial
reference.
Can this sequence cause a double-free and use-after-free on the already freed
bridge pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716230411.2767394-1-tarunsahu@google.com?part=6
next prev parent reply other threads:[~2026-07-17 2:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 23:04 [PATCH v19 0/7] shut down devices asynchronously Tarun Sahu
2026-07-16 23:04 ` [PATCH v19 1/7] device_core: rely on put_device to free dev->p Tarun Sahu
2026-07-17 3:04 ` sashiko-bot
2026-07-16 23:04 ` [PATCH v19 2/7] driver core: Prevent device_add() during system shutdown Tarun Sahu
2026-07-17 3:15 ` sashiko-bot
2026-07-16 23:04 ` [PATCH v19 3/7] driver core: separate function to shutdown one device Tarun Sahu
2026-07-17 2:49 ` sashiko-bot
2026-07-16 23:04 ` [PATCH v19 4/7] driver core: do not always lock parent in shutdown Tarun Sahu
2026-07-17 2:59 ` sashiko-bot
2026-07-16 23:04 ` [PATCH v19 5/7] driver core: async device shutdown infrastructure Tarun Sahu
2026-07-17 2:51 ` sashiko-bot
2026-07-16 23:04 ` [PATCH v19 6/7] PCI: Enable async shutdown support Tarun Sahu
2026-07-17 2:56 ` sashiko-bot [this message]
2026-07-16 23:04 ` [PATCH v19 7/7] scsi: " Tarun Sahu
2026-07-17 3:00 ` 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=20260717025634.0DBCA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tarunsahu@google.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