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 <john.zhao@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34182 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
b8501c7c5f
commit
1ceac4efcf
|
@ -241,7 +241,7 @@ void fast_spi_cache_bios_region(void)
|
||||||
* protection, so limit the cached bios region to be no more than 16MB.
|
* protection, so limit the cached bios region to be no more than 16MB.
|
||||||
* */
|
* */
|
||||||
bios_size = MIN(bios_size, 16 * MiB);
|
bios_size = MIN(bios_size, 16 * MiB);
|
||||||
if (!bios_size)
|
if (bios_size <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Round to power of two */
|
/* Round to power of two */
|
||||||
|
|
|
@ -80,7 +80,7 @@ void lpc_open_pmio_window(uint16_t base, uint16_t size)
|
||||||
/* Each IO range register can only open a 256-byte window. */
|
/* Each IO range register can only open a 256-byte window. */
|
||||||
window_size = MIN(size, LPC_LGIR_MAX_WINDOW_SIZE);
|
window_size = MIN(size, LPC_LGIR_MAX_WINDOW_SIZE);
|
||||||
|
|
||||||
if (!window_size)
|
if (window_size <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Window size must be a power of two for the AMASK to work. */
|
/* Window size must be a power of two for the AMASK to work. */
|
||||||
|
|
Loading…
Reference in New Issue