summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2017-09-28 17:52:59 -0600
committerAaron Durbin <adurbin@chromium.org>2017-10-02 17:16:14 +0000
commitcf20c904302f19591069b004dd8e1f747c9cd6fc (patch)
treedfa76ffd72bf457c00a0568bd31f0ebf0dd92171 /util
parent7c48b891fe72b5d9e586f8cac86817bd922433e7 (diff)
downloadcoreboot-cf20c904302f19591069b004dd8e1f747c9cd6fc.tar.xz
util/cbmem: fix feedback for 'be explicit about memory map sizes'
Julius made some suggestions to fix/improve commit 46300aa2. Implement those. BUG=b:66681446 Change-Id: I6becac9ffdcc65745e88734dfb80d12b581584a1 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/21757 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbmem/cbmem.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index b4f41d2072..dea2c0b11e 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -102,7 +102,7 @@ static const void *mapping_virt(const struct mapping *mapping)
return v + mapping->offset;
}
-/* Returns 0 on success, < 0 on error. mapping is filled in. */
+/* Returns virtual address on success, NULL on error. mapping is filled in. */
static const void *map_memory(struct mapping *mapping, unsigned long long phys,
size_t sz)
{
@@ -378,14 +378,11 @@ static int parse_cbtable(u64 address, size_t table_size)
return -1;
/* look at every 16 bytes */
- for (i = 0; i < req_size; i += 16) {
+ for (i = 0; i <= req_size - sizeof(struct lb_header); i += 16) {
int ret;
const struct lb_header *lbh;
struct mapping table_mapping;
- if (req_size - i < sizeof(struct lb_header))
- return -1;
-
lbh = buf + i;
if (memcmp(lbh->signature, "LBIO", sizeof(lbh->signature)) ||
!lbh->header_bytes ||