summaryrefslogtreecommitdiff
path: root/src/lib/cbfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/cbfs.c')
-rw-r--r--src/lib/cbfs.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index aba1bcccf0..400b8a5f9d 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -112,7 +112,7 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor,
if (! dest)
return src;
- if (cbfs_decompress(ntohl(orom->compression),
+ if (!cbfs_decompress(ntohl(orom->compression),
src,
dest,
ntohl(orom->len)))
@@ -204,8 +204,8 @@ static void *load_stage_from_cbfs(struct cbfs_media *media, const char *name,
LOG("Decompressing stage %s @ 0x%p (%d bytes)\n",
name, &ramstage_region[rmodule_offset], stage->memlen);
- if (cbfs_decompress(stage->compression, &stage[1],
- &ramstage_region[rmodule_offset], stage->len))
+ if (!cbfs_decompress(stage->compression, &stage[1],
+ &ramstage_region[rmodule_offset], stage->len))
return (void *) -1;
if (rmodule_parse(&ramstage_region[rmodule_offset], &ramstage))
@@ -259,6 +259,7 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name)
/* this is a mess. There is no ntohll. */
/* for now, assume compatible byte order until we solve this. */
uint32_t entry;
+ uint32_t final_size;
if (stage == NULL)
return (void *) -1;
@@ -270,11 +271,12 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name)
/* Stages rely the below clearing so that the bss is initialized. */
memset((void *) (uint32_t) stage->load, 0, stage->memlen);
- if (cbfs_decompress(stage->compression,
- ((unsigned char *) stage) +
- sizeof(struct cbfs_stage),
- (void *) (uint32_t) stage->load,
- stage->len))
+ final_size = cbfs_decompress(stage->compression,
+ ((unsigned char *) stage) +
+ sizeof(struct cbfs_stage),
+ (void *) (uint32_t) stage->load,
+ stage->len);
+ if (!final_size)
return (void *) -1;
DEBUG("stage loaded.\n");