Fix alignment bug in pci_bios_init_root_regions().
authorKevin O'Connor <kevin@koconnor.net>
Sat, 1 Oct 2011 16:35:32 +0000 (12:35 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 1 Oct 2011 16:42:51 +0000 (12:42 -0400)
If there are no memory allocations for a given type then the "max" bar
size is zero.  However, ALIGN_DOWN does not handle an alignment of
zero properly.  Catch and handle the zero case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/pciinit.c

index a857da06969b0a0cc362cc7192c28ae1c9d85c65..0d8758e292aa5d9cfc7273f5552cf5a01b96f6dd 100644 (file)
@@ -536,7 +536,7 @@ static void pci_bios_init_bus_bases(struct pci_bus *bus)
     }
 }
 
-#define ROOT_BASE(top, sum, align) ALIGN_DOWN((top)-(sum),(align))
+#define ROOT_BASE(top, sum, max) ALIGN_DOWN((top)-(sum),(max) ?: 1)
 
 static int pci_bios_init_root_regions(u32 start, u32 end)
 {