
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com --- fs/cbfs/cbfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index 7b2513cb24..c60a8d5dc1 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -162,13 +162,10 @@ static void file_cbfs_fill_cache(u8 *start, u32 size, u32 align) }
/* Get the CBFS header out of the ROM and do endian conversion. */ -static int file_cbfs_load_header(uintptr_t end_of_rom, - struct cbfs_header *header) +static int file_cbfs_load_header(uintptr_t addr, struct cbfs_header *header) { - struct cbfs_header *header_in_rom; - int32_t offset = *(u32 *)(end_of_rom - 3); + struct cbfs_header *header_in_rom = (struct cbfs_header *)addr;
- header_in_rom = (struct cbfs_header *)(end_of_rom + offset + 1); swap_header(header, header_in_rom);
if (header->magic != good_magic || header->offset > @@ -183,8 +180,9 @@ void file_cbfs_init(uintptr_t end_of_rom) { u8 *start_of_rom; initialized = 0; + const int32_t offset = *(u32 *)(end_of_rom - 3);
- if (file_cbfs_load_header(end_of_rom, &cbfs_header)) + if (file_cbfs_load_header(end_of_rom + offset + 1, &cbfs_header)) return;
start_of_rom = (u8 *)(end_of_rom + 1 - cbfs_header.rom_size);