Skip to content

Commit e542232

Browse files
rosslagerwallbjorn-helgaas
authored andcommitted
PCI: Release resource invalidated by coalescing
When contiguous windows are coalesced by pci_register_host_bridge(), the second resource is expanded to include the first, and the first is invalidated and consequently not added to the bus. However, it remains in the resource hierarchy. For example, these windows: fec00000-fec7ffff : PCI Bus 0000:00 fec80000-fecbffff : PCI Bus 0000:00 are coalesced into this, where the first resource remains in the tree with start/end zeroed out: 00000000-00000000 : PCI Bus 0000:00 fec00000-fecbffff : PCI Bus 0000:00 In some cases (e.g. the Xen scratch region), this causes future calls to allocate_resource() to choose an inappropriate location which the caller cannot handle. Fix by releasing the zeroed-out resource and removing it from the resource hierarchy. [bhelgaas: commit log] Fixes: 7c3855c ("PCI: Coalesce host bridge contiguous apertures") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ross Lagerwall <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: [email protected] # v5.16+
1 parent ac9a786 commit e542232

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pci/probe.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
997997
resource_list_for_each_entry_safe(window, n, &resources) {
998998
offset = window->offset;
999999
res = window->res;
1000-
if (!res->flags && !res->start && !res->end)
1000+
if (!res->flags && !res->start && !res->end) {
1001+
release_resource(res);
10011002
continue;
1003+
}
10021004

10031005
list_move_tail(&window->node, &bridge->windows);
10041006

0 commit comments

Comments
 (0)