summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/cbfs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 32b50da30c..52f73736da 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -309,8 +309,15 @@ void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg,
loc = allocator(arg, size, &mdata);
} else if (compression == CBFS_COMPRESS_NONE) {
void *mapping = rdev_mmap_full(&rdev);
- if (!mapping || cbfs_file_hash_mismatch(mapping, size, file_hash))
+
+ if (!mapping)
+ return NULL;
+
+ if (cbfs_file_hash_mismatch(mapping, size, file_hash)) {
+ rdev_munmap(&rdev, mapping);
return NULL;
+ }
+
return mapping;
} else if (!CBFS_CACHE_AVAILABLE) {
ERROR("Cannot map compressed file %s on x86\n", mdata.h.filename);