Arthur Heymans has uploaded this change for review.

View Change

util/cbfstool/fit.c: Bail out when there are not enough FIT entries

Bail out when there are not enough empty FIT enties to add all
microcode entries.

Change-Id: If86678a1eaaa0c5ff571f25bd6bfdb26ac93a946
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
M util/cbfstool/fit.c
1 file changed, 8 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/33555/1
diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c
index aeb1755..2fee9e3 100644
--- a/util/cbfstool/fit.c
+++ b/util/cbfstool/fit.c
@@ -238,7 +238,7 @@
static int parse_microcode_blob(struct cbfs_image *image,
struct cbfs_file *mcode_file,
struct microcode_entry *mcus,
- int total_entries, int *mcus_found)
+ int *mcus_found)
{
int num_mcus;
uint32_t current_offset;
@@ -272,9 +272,6 @@
file_length -= mcus[num_mcus].size;
num_mcus++;

- /* Reached limit of FIT entries. */
- if (num_mcus == total_entries)
- break;
if (file_length < sizeof(struct microcode_header))
break;
}
@@ -319,13 +316,18 @@
return 1;
}

- if (parse_microcode_blob(image, mcode_file, mcus, empty_entries,
- &mcus_found)) {
+ if (parse_microcode_blob(image, mcode_file, mcus, &mcus_found)) {
ERROR("Couldn't parse microcode blob.\n");
ret = 1;
goto out;
}

+ if (mcus_found > empty_entries) {
+ ERROR("Not enough empty FIT entries for all microcode update entries.\n");
+ ret = 1;
+ goto out;
+ }
+
add_microcodde_entries(fit, image, mcus_found, mcus, offset_fn, 0);

update_fit_checksum(fit);

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If86678a1eaaa0c5ff571f25bd6bfdb26ac93a946
Gerrit-Change-Number: 33555
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange