summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2013-10-28 20:00:50 -0700
committerPatrick Georgi <patrick@georgi-clan.de>2014-08-10 22:28:10 +0200
commit586460b24276d944deed1d3c599bcae96457a1db (patch)
treebfa876d97caea94e051985aabece98fd0d1759c9 /src
parent141512161b40666e83094d8d99c544ce9a74ab8f (diff)
downloadcoreboot-586460b24276d944deed1d3c599bcae96457a1db.tar.xz
cbfs: Check return value of map() for error
The CBFS core checks the result of a media->map() operation in multiple places for CBFS_MEDIA_INVALID_MAP_ADDRESS, suggesting that this is a valid response. However, it ironically fails to do so when actually mapping the CBFS file itself, which can fail on buffer-constrained systems since the size is much larger than when mapping metadata. This patch adds a check with an error message and a NULL pointer return for that case to make it easier to understand this condition. Change-Id: Icae3dd20d3d111cdfc4f2dc6397b52174349b140 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174951 Reviewed-by: Gabe Black <gabeblack@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> (cherry picked from commit 63f2c4465f9633a637186e69bc3862d5413106ac) Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com> Reviewed-on: http://review.coreboot.org/6537 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/cbfs_core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c
index 264d9a8f24..19cf83a41d 100644
--- a/src/lib/cbfs_core.c
+++ b/src/lib/cbfs_core.c
@@ -167,6 +167,11 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
file_ptr = media->map(media, offset,
file_offset + file_len);
media->close(media);
+ if (file_ptr == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
+ ERROR("ERROR: Mapping %s failed (insufficient "
+ "buffer space?).\n", file_name);
+ return NULL;
+ }
return file_ptr;
} else {
DEBUG(" (unmatched file @0x%x: %s)\n", offset,