From 72ef5b20f05652152ac627f027264c3b0441d693 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Mon, 18 Jul 2016 07:59:03 -0700 Subject: [PATCH] UPSTREAM: soc/intel/apollolake: Fix bitshift issue in bootblock Fix issue where zero-sized BIOS region could cause bitshift for '-1' which is an unspecified behavior. BUG=None BRANCH=None TEST=None Signed-off-by: Andrey Petrov Reviewed-on: https://review.coreboot.org/15727 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Change-Id: Icb62bf413a1a0d293657503ef21fe97b5f9a5484 Reviewed-on: https://chromium-review.googlesource.com/361645 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/soc/intel/apollolake/bootblock/bootblock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/soc/intel/apollolake/bootblock/bootblock.c b/src/soc/intel/apollolake/bootblock/bootblock.c index 8c1ff919d1..31144ff219 100644 --- a/src/soc/intel/apollolake/bootblock/bootblock.c +++ b/src/soc/intel/apollolake/bootblock/bootblock.c @@ -98,7 +98,10 @@ static void cache_bios_region(void) return; /* Only the IFD BIOS region is memory mapped (at top of 4G) */ - rom_size = get_bios_size(); + rom_size = get_bios_size(); + + if (!rom_size) + return; /* Round to power of two */ alignment = 1 << (log2_ceil(rom_size));