From 1ceac4efcfa3a9ccc0d44f77855f4949f59305b5 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Tue, 9 Jul 2019 14:27:28 -0700 Subject: soc/intel/common: Check bios_size and window_size after MIN operation Clang Static Analyzer version 8.0.0 detects that the result of log2_ceil(bios_size) and log2_ceil(window_size) is undefined if the value of bios_size and window_size are negative. Add negative value Check for bios_size and window_size after MIN operation. Change-Id: I28577b6e0ba0ab45bb7804c17ba1f26c4b078b15 Signed-off-by: John Zhao Reviewed-on: https://review.coreboot.org/c/coreboot/+/34182 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/intel/common/block/fast_spi/fast_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/soc/intel/common/block/fast_spi') diff --git a/src/soc/intel/common/block/fast_spi/fast_spi.c b/src/soc/intel/common/block/fast_spi/fast_spi.c index e40b84493e..5c29addcc9 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi.c @@ -241,7 +241,7 @@ void fast_spi_cache_bios_region(void) * protection, so limit the cached bios region to be no more than 16MB. * */ bios_size = MIN(bios_size, 16 * MiB); - if (!bios_size) + if (bios_size <= 0) return; /* Round to power of two */ -- cgit v1.2.3