From 20f5dcec63ade1108e8ebaa6a34665aa9273db99 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Thu, 3 Dec 2020 12:25:11 -0800 Subject: [PATCH] cbfs: mcache: Fix end-of-cache check After the mcache is copied into CBMEM, it has *just* the right size to fit the final tag with no room to spare. That means the test to check if we walked over the end must be `current + sizeof(tag) <= end`, not `current + sizeof(tag) < end`. Signed-off-by: Julius Werner Change-Id: I25a0d774fb3294bb4d15f31f432940bfccc84af0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/48277 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/commonlib/bsd/cbfs_mcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonlib/bsd/cbfs_mcache.c b/src/commonlib/bsd/cbfs_mcache.c index d2f969dbc3..0d5d8e0221 100644 --- a/src/commonlib/bsd/cbfs_mcache.c +++ b/src/commonlib/bsd/cbfs_mcache.c @@ -95,7 +95,7 @@ cb_err_t cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char * const void *end = mcache + mcache_size; const void *current = mcache; - while (current + sizeof(uint32_t) < end) { + while (current + sizeof(uint32_t) <= end) { const union mcache_entry *entry = current; if (entry->magic == MCACHE_MAGIC_END)