lib/imd: Improve check to filter out 0-size imd_entries

Previously it was allowed to create an imd_entry with size 0, however
algorithm sets the offset of such entry to the exact same address as
the last registered entry.

Signed-off-by: Jan Dabros <jsd@semihalf.com>
Change-Id: Ifa2cdc887381fb0d268e2c199e868b038aafff5f
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44666
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
This commit is contained in:
Jan Dabros 2020-08-20 08:29:49 +02:00 committed by Patrick Georgi
parent fc83588e85
commit 93d56f5165

View File

@ -323,7 +323,7 @@ static struct imd_entry *imd_entry_add_to_root(struct imd_root *r, uint32_t id,
last_entry = root_last_entry(r);
e_offset = last_entry->start_offset;
e_offset -= (ssize_t)used_size;
if (e_offset > last_entry->start_offset)
if (e_offset >= last_entry->start_offset)
return NULL;
entry = root_last_entry(r) + 1;