include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / x86 / pci / mmconfig-shared.c
index b19d1e54201ee95a80d8123e9ba26716811c52fe..39b9ebe8f8863d598345991c90942b5aed70ae21 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sfi_acpi.h>
 #include <linux/bitmap.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include <asm/e820.h>
 #include <asm/pci_x86.h>
 #include <asm/acpi.h>
@@ -303,22 +304,17 @@ static void __init pci_mmcfg_check_end_bus_number(void)
 {
        struct pci_mmcfg_region *cfg, *cfgx;
 
-       /* last one*/
-       cfg = list_entry(pci_mmcfg_list.prev, typeof(*cfg), list);
-       if (cfg)
-               if (cfg->end_bus < cfg->start_bus)
-                       cfg->end_bus = 255;
-
-       if (list_is_singular(&pci_mmcfg_list))
-               return;
-
-       /* don't overlap please */
+       /* Fixup overlaps */
        list_for_each_entry(cfg, &pci_mmcfg_list, list) {
                if (cfg->end_bus < cfg->start_bus)
                        cfg->end_bus = 255;
 
+               /* Don't access the list head ! */
+               if (cfg->list.next == &pci_mmcfg_list)
+                       break;
+
                cfgx = list_entry(cfg->list.next, typeof(*cfg), list);
-               if (cfg != cfgx && cfg->end_bus >= cfgx->start_bus)
+               if (cfg->end_bus >= cfgx->start_bus)
                        cfg->end_bus = cfgx->start_bus - 1;
        }
 }