Re: [PATCH 1/7] s390/pci: fix double-free in zpci MSI cleanup

"Tobias Schumacher" <[email protected]>
Newsgroups org.kernel.vger.linux-s390,dev.linux.lists.sashiko-reviews
Message-ID <[email protected]>
On Wed Aug 19, 2026 at 11:03 AM CEST, sashiko-bot wrote:
> 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.
> --

-- snip --

> [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?

Yes, seems like pci_free_resource_list() should be moved outside the if
block. But this should be fixed in a separate patch outside this series
since it is unrelated to the introduction of the irq domains.

Tobias
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.