PCI: Converge return paths in __assign_resources_sorted()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 16 Dec 2024 17:56:19 +0000 (19:56 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 18 Feb 2025 21:40:53 +0000 (15:40 -0600)
All return paths want to free head list in __assign_resources_sorted(), so
add a label and use goto.

Link: https://lore.kernel.org/r/20241216175632.4175-13-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>
drivers/pci/setup-bus.c

index 916474af56ad66fd4617d824c4a3c52439d017b9..8fda0354e54387221819ed5bd7a63ca41c320c03 100644 (file)
@@ -444,8 +444,7 @@ static void __assign_resources_sorted(struct list_head *head,
                list_for_each_entry(dev_res, head, list)
                        remove_from_list(realloc_head, dev_res->res);
                free_list(&save_head);
-               free_list(head);
-               return;
+               goto out;
        }
 
        /* Check failed type */
@@ -488,6 +487,8 @@ requested_and_reassign:
        /* Try to satisfy any additional optional resource requests */
        if (realloc_head)
                reassign_resources_sorted(realloc_head, head);
+
+out:
        free_list(head);
 }