Skip to content

Commit b3281eb

Browse files
ij-intelbjorn-helgaas
authored andcommitted
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/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Xiaochun Lee <[email protected]>
1 parent 9caf4ea commit b3281eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pci/setup-bus.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,18 @@ static void __assign_resources_sorted(struct list_head *head,
400400
*/
401401
LIST_HEAD(save_head);
402402
LIST_HEAD(local_fail_head);
403+
LIST_HEAD(dummy_head);
403404
struct pci_dev_resource *save_res;
404405
struct pci_dev_resource *dev_res, *tmp_res, *dev_res2;
405406
struct resource *res;
406407
unsigned long fail_type;
407408
resource_size_t add_align, align;
408409

410+
if (!realloc_head)
411+
realloc_head = &dummy_head;
412+
409413
/* Check if optional add_size is there */
410-
if (!realloc_head || list_empty(realloc_head))
414+
if (list_empty(realloc_head))
411415
goto requested_and_reassign;
412416

413417
/* Save original start, end, flags etc at first */
@@ -503,7 +507,7 @@ static void __assign_resources_sorted(struct list_head *head,
503507
assign_requested_resources_sorted(head, fail_head);
504508

505509
/* Try to satisfy any additional optional resource requests */
506-
if (realloc_head)
510+
if (!list_empty(realloc_head))
507511
reassign_resources_sorted(realloc_head, head);
508512

509513
out:

0 commit comments

Comments
 (0)