From: sashiko-bot@kernel.org
To: "Tobias Schumacher" <ts@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 1/7] s390/pci: fix double-free in zpci MSI cleanup
Date: Wed, 19 Aug 2026 09:03:08 +0000 [thread overview]
Message-ID: <20260819090308.A0A2C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819-s390_irq_domain_fixes-v1-1-826ff27b6e97@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] Pre-existing memory leak of `struct resource_entry` in `zbus->resources` when PCI root bus creation fails.
--
--- Patch [1]: [PATCH 1/7] s390/pci: fix double-free in zpci MSI cleanup ---
commit d582c0ae794fba4fb3a5cf7c09155cbe33bdffb9
Author: Tobias Schumacher <ts@linux.ibm.com>
s390/pci: fix double-free in zpci MSI cleanup
zpci_remove_parent_msi_domain() can be called multiple times on the
same zbus, causing a double-free. This occurs when pci_create_root_bus()
fails after successful MSI domain creation in zpci_bus_create_pci_bus():
the error path calls zpci_remove_parent_msi_domain() to clean up, but
doesn't NULL the pointer. Later, when zpci_bus_release() is called via
kref_put(), it calls zpci_remove_parent_msi_domain() again, attempting
to free the already-freed domain and fwnode.
Add NULL check at function entry and NULL the pointer after cleanup to
make the function idempotent and safe for multiple calls.
Fixes: f770950a4709 ("s390/pci: Migrate s390 IRQ logic to IRQ domain API")
Cc: stable@vger.kernel.org
Signed-off-by: Tobias Schumacher <ts@linux.ibm.com>
> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
> index 9c9ed3d8d9597..c9520a16ca753 100644
> --- a/arch/s390/pci/pci_irq.c
> +++ b/arch/s390/pci/pci_irq.c
[Severity: Medium]
This is a pre-existing issue, but while reviewing the error path discussed in
the commit message (when pci_create_root_bus() fails), does zpci_bus_release()
leak zbus->resources?
In arch/s390/pci/pci_bus.c:zpci_bus_alloc(), a resource is added to the list:
INIT_LIST_HEAD(&zbus->resources);
zbus->bus_resource.start = 0;
zbus->bus_resource.end = ZPCI_BUS_NR;
zbus->bus_resource.flags = IORESOURCE_BUS;
pci_add_resource(&zbus->resources, &zbus->bus_resource);
But in the error path where pci_create_root_bus() fails, zbus->bus is not set.
Later in zpci_bus_release(), pci_free_resource_list() is only called if
zbus->bus is true:
if (zbus->bus) {
pci_lock_rescan_remove();
pci_stop_root_bus(zbus->bus);
zpci_free_domain(zbus->domain_nr);
pci_free_resource_list(&zbus->resources);
pci_remove_root_bus(zbus->bus);
pci_unlock_rescan_remove();
}
Can this leak the struct resource_entry on this initialization error path?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819-s390_irq_domain_fixes-v1-0-826ff27b6e97@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-08-19 9:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 8:50 [PATCH 0/7] s390/pci: Fix multiple bugs in IRQ domain migration Tobias Schumacher
2026-08-19 8:50 ` [PATCH 1/7] s390/pci: fix double-free in zpci MSI cleanup Tobias Schumacher
2026-08-19 9:03 ` sashiko-bot [this message]
2026-08-19 8:50 ` [PATCH 2/7] s390/pci: fix use-after-free race in zpci floating interrupt cleanup Tobias Schumacher
2026-08-19 9:20 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 3/7] s390/pci: fix resource leak in zpci MSI setup Tobias Schumacher
2026-08-19 9:05 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 4/7] s390/pci: fix MSI directed-mode teardown IRQ bit count Tobias Schumacher
2026-08-19 9:07 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 5/7] s390/pci: add NULL check in zpci_msi_clear_airq() Tobias Schumacher
2026-08-19 9:14 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 6/7] s390/pci: add error cleanup in zpci_directed_irq_init Tobias Schumacher
2026-08-19 9:02 ` sashiko-bot
2026-08-19 8:51 ` [PATCH 7/7] s390/pci: move MSI affinity flag initialization to boot time Tobias Schumacher
2026-08-19 9:06 ` sashiko-bot
2026-08-19 9:24 ` [PATCH 0/7] s390/pci: Fix multiple bugs in IRQ domain migration Niklas Schnelle
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=20260819090308.A0A2C1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=ts@linux.ibm.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