]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PCI: Consolidate add_list (aka realloc_head) empty sanity checks
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 29 Apr 2026 12:26:09 +0000 (15:26 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 17:08:21 +0000 (12:08 -0500)
commit2c90aeab5a5598f8bb17214579a889f1eed71bdc
treea8176be0807b8d4cea4575cc80c6afe2ace77ad9
parent29bfc3523fa4e41aef2b67ce086dbfb2ccb2564f
PCI: Consolidate add_list (aka realloc_head) empty sanity checks

Callers of __pci_bridge_assign_resources() and __pci_bus_assign_resources()
perform WARN_ON_ONCE(list_empty(add_list))) checks to sanity check that all
optional sizes were processed (and removed) from the list. The empty list
sanity check is duplicated code so the more appropriate place for it would
be inside the called function.

Placing the empty list check into __pci_bus_assign_resources() also ensures
all callsites do perform the sanity check which currently is not the case
when being called from enable_slot(). This inconsistency was noted by
Sashiko though only inside its in depth log but not flagged as a real
problem, possibly because this is only a sanity check that should never
fire. Nonetheless, this sanity check has been very useful to catch problems
early in the past so it's good to do it consistently everywhere.

As __pci_bus_assign_resources() is a recursive function, it needs to be
renamed to __pci_bus_assign_resources_one() to only perform the empty list
check at the end of processing the entire hierarchy in
__pci_bus_assign_resources().

Suggested-by: sashiko.dev # Sanity check missing from enable_slot()
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260429122617.7324-4-ilpo.jarvinen@linux.intel.com
drivers/pci/setup-bus.c