lib/cbfs: Call rdev_unmap on hash mismatch
We don't want to leak any mappings. BUG=b:179699789 TEST=none Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ibcd28ce12cbd5e221e8f4fa910fd8472bedb802f Reviewed-on: https://review.coreboot.org/c/coreboot/+/56576 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
		
				
					committed by
					
						
						Felix Held
					
				
			
			
				
	
			
			
			
						parent
						
							4396358fd3
						
					
				
				
					commit
					3f41d3269e
				
			@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user