From b0b31da336fa2f87fe73f063782d6243f8262d10 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 18 Sep 2014 13:47:33 -0700 Subject: [PATCH] cbfs: more accurate size check for simple buffer mapping currently, if the cache size is, for example, 4096 byte, mapping 4096 byte data fails due to the overly strict check. this change allows cbfs_simple_buffer_map to use all the cache space to the last byte. BUG=None TEST=Booted Nyan Blaze. BRANCH=None Signed-off-by: Daisuke Nojiri Change-Id: I0797b5010afd7316fdec605784e8f48e2d62c37f Reviewed-on: https://chromium-review.googlesource.com/218883 Commit-Queue: Daisuke Nojiri Tested-by: Daisuke Nojiri Reviewed-by: Aaron Durbin --- src/lib/cbfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 9c7dc5e86e..8cd8e084ae 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -365,7 +365,7 @@ void *cbfs_simple_buffer_map(struct cbfs_simple_buffer *buffer, "allocated=%zd, size=%zd, last_allocate=%zd\n", offset, count, buffer->allocated, buffer->size, buffer->last_allocate); - if (buffer->allocated + count >= buffer->size) + if (buffer->allocated + count > buffer->size) return CBFS_MEDIA_INVALID_MAP_ADDRESS; if (media->read(media, address, offset, count) != count) { ERROR("simple_buffer: fail to read %zd bytes from 0x%zx\n",