diff options
| author | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2024-12-16 20:56:27 +0300 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2025-02-19 00:40:54 +0300 |
| commit | b3281eb5ded17f88d7d4fa5fb39a709c195e56c2 (patch) | |
| tree | f8f42956a84b8be3a157b5bb617b84847127f5e9 | |
| parent | 9caf4ea2fd022e3febb8f70421b7f87e9788852e (diff) | |
| download | linux-b3281eb5ded17f88d7d4fa5fb39a709c195e56c2.tar.xz | |
PCI: Always have realloc_head in __assign_resources_sorted()
Add a dummy list to always have a non-NULL realloc head in
__assign_resources_sorted() as it allows only checking list_empty().
In future, it would be good to ensure all callers provide a valid
realloc_head but that is relatively complex to do in practice and not
necessary for the subsequent optional resource handling fix.
Link: https://lore.kernel.org/r/20241216175632.4175-21-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Xiaochun Lee <lixc17@lenovo.com>
| -rw-r--r-- | drivers/pci/setup-bus.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 0b11069938b6..aa092644808b 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -400,14 +400,18 @@ static void __assign_resources_sorted(struct list_head *head, */ LIST_HEAD(save_head); LIST_HEAD(local_fail_head); + LIST_HEAD(dummy_head); struct pci_dev_resource *save_res; struct pci_dev_resource *dev_res, *tmp_res, *dev_res2; struct resource *res; unsigned long fail_type; resource_size_t add_align, align; + if (!realloc_head) + realloc_head = &dummy_head; + /* Check if optional add_size is there */ - if (!realloc_head || list_empty(realloc_head)) + if (list_empty(realloc_head)) goto requested_and_reassign; /* Save original start, end, flags etc at first */ @@ -503,7 +507,7 @@ requested_and_reassign: assign_requested_resources_sorted(head, fail_head); /* Try to satisfy any additional optional resource requests */ - if (realloc_head) + if (!list_empty(realloc_head)) reassign_resources_sorted(realloc_head, head); out: |
