mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
efi_loader: fix efi_image_region_add()
Use start and end address consistently as half-open interval. Simplify the code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
bc246c69ae
commit
28164c925e
1 changed files with 19 additions and 16 deletions
|
@ -521,15 +521,19 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* efi_image_region_add - add an entry of region
|
* efi_image_region_add() - add an entry of region
|
||||||
* @regs: Pointer to array of regions
|
* @regs: Pointer to array of regions
|
||||||
* @start: Start address of region
|
* @start: Start address of region (included)
|
||||||
* @end: End address of region
|
* @end: End address of region (excluded)
|
||||||
* @nocheck: flag against overlapped regions
|
* @nocheck: flag against overlapped regions
|
||||||
*
|
*
|
||||||
* Take one entry of region [@start, @end] and append it to the list
|
* Take one entry of region [@start, @end[ and insert it into the list.
|
||||||
* pointed to by @regs. If @nocheck is false, overlapping among entries
|
*
|
||||||
* will be checked first.
|
* * If @nocheck is false, the list will be sorted ascending by address.
|
||||||
|
* Overlapping entries will not be allowed.
|
||||||
|
*
|
||||||
|
* * If @nocheck is true, the list will be sorted ascending by sequence
|
||||||
|
* of adding the entries. Overlapping is allowed.
|
||||||
*
|
*
|
||||||
* Return: status code
|
* Return: status code
|
||||||
*/
|
*/
|
||||||
|
@ -553,22 +557,21 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs,
|
||||||
if (nocheck)
|
if (nocheck)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (start > reg->data + reg->size)
|
/* new data after registered region */
|
||||||
|
if (start >= reg->data + reg->size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((start >= reg->data && start < reg->data + reg->size) ||
|
/* new data preceding registered region */
|
||||||
(end > reg->data && end < reg->data + reg->size)) {
|
if (end <= reg->data) {
|
||||||
EFI_PRINT("%s: new region already part of another\n",
|
|
||||||
__func__);
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start < reg->data && end < reg->data + reg->size) {
|
|
||||||
for (j = regs->num - 1; j >= i; j--)
|
for (j = regs->num - 1; j >= i; j--)
|
||||||
memcpy(®s->reg[j], ®s->reg[j + 1],
|
memcpy(®s->reg[j + 1], ®s->reg[j],
|
||||||
sizeof(*reg));
|
sizeof(*reg));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* new data overlapping registered region */
|
||||||
|
EFI_PRINT("%s: new region already part of another\n", __func__);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = ®s->reg[i];
|
reg = ®s->reg[i];
|
||||||
|
|
Loading…
Reference in a new issue