lib: Throw an error when ramdisk is present but initrd.size is 0

It fails if you call extract() when ramdisk is present but initrd
size is 0. This CL adds if-statement to throw an error when initrd
size is 0.

Change-Id: I85aa33d2c2846b6b3a58df834dda18c47433257d
Signed-off-by: Asami Doi <d0iasm.pub@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34535
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Asami Doi 2019-07-24 16:04:20 +09:00 committed by Julius Werner
parent b8f1bd7a37
commit 02547c5886
1 changed files with 5 additions and 0 deletions

View File

@ -51,6 +51,11 @@ static bool extract(struct region *region, struct fit_image_node *node)
const char *comp_name;
size_t true_size = 0;
if (node->size == 0) {
printk(BIOS_ERR, "ERROR: The %s size is 0\n", node->name);
return true;
}
switch (node->compression) {
case CBFS_COMPRESS_NONE:
comp_name = "Relocating uncompressed";