Asami Doi has uploaded this change for review.

View Change

lib: Call extract() only when initrd.size is more than 0

This CL avoid the fail that happens when initrd.size is 0. extract()
returns false even though initrd.size is already 0. In the case of
size is 0, we don't know extract it, so call extract() only when
initrd.size is more than 0.

Signed-off-by: Asami Doi <d0iasm.pub@gmail.com>
Change-Id: I85aa33d2c2846b6b3a58df834dda18c47433257d
---
M src/lib/fit_payload.c
1 file changed, 7 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/34535/1
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index a4d3705..57cd4a5 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -246,12 +246,13 @@
/* Repack FDT for handoff to kernel */
pack_fdt(&fdt, dt);

- if (config->ramdisk &&
- extract(&initrd, config->ramdisk)) {
- printk(BIOS_ERR, "ERROR: Failed to extract initrd\n");
- prog_set_entry(payload, NULL, NULL);
- rdev_munmap(prog_rdev(payload), data);
- return;
+ if (config->ramdisk && initrd.size > 0) {
+ if (extract(&initrd, config->ramdisk)) {
+ printk(BIOS_ERR, "ERROR: Failed to extract initrd\n");
+ prog_set_entry(payload, NULL, NULL);
+ rdev_munmap(prog_rdev(payload), data);
+ return;
+ }
}

timestamp_add_now(TS_KERNEL_DECOMPRESSION);

To view, visit change 34535. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I85aa33d2c2846b6b3a58df834dda18c47433257d
Gerrit-Change-Number: 34535
Gerrit-PatchSet: 1
Gerrit-Owner: Asami Doi <d0iasm.pub@gmail.com>
Gerrit-MessageType: newchange