]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: efi: Avoid out-of-bounds write in meminfo_add_bank
authorJulien Grall <julien.grall@arm.com>
Thu, 4 May 2017 19:36:41 +0000 (20:36 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Thu, 4 May 2017 22:00:18 +0000 (15:00 -0700)
Commit 2c77db77 "xen/arm: efi: Avoid duplicating the addition of a new
bank", introduced a new function meminfo_add_bank that add a new bank.
This new code fails to check correctly the size of the array which may
result to an out-of-bounds write.

Coverity-ID: 1433183
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/efi/efi-boot.h

index e1e447ac8e0d5e8426c7a60559f43081cf70f54d..2986c834473d7c54a701da45f5d625a8af7f7d71 100644 (file)
@@ -128,7 +128,7 @@ static bool __init meminfo_add_bank(struct meminfo *mem,
 {
     struct membank *bank;
 
-    if ( mem->nr_banks > NR_MEM_BANKS )
+    if ( mem->nr_banks >= NR_MEM_BANKS )
         return false;
 
     bank = &mem->bank[mem->nr_banks];