]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: Keep memory mapping sorted when splitting an entry
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Sat, 1 Oct 2016 21:32:28 +0000 (23:32 +0200)
committerAlexander Graf <agraf@suse.de>
Tue, 18 Oct 2016 07:08:07 +0000 (09:08 +0200)
The code assumes sorted mappings in descending address order. When
splitting a mapping, insert the new part next to the current mapping.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_memory.c

index d3a2ffdac68ad87c75ef8d192dd397bd7aefea30..742bc9084ffc32678649188be807ed39c662b8ed 100644 (file)
@@ -135,7 +135,8 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
        newmap->desc = map->desc;
        newmap->desc.physical_start = carve_start;
        newmap->desc.num_pages = (map_end - carve_start) >> EFI_PAGE_SHIFT;
-        list_add_tail(&newmap->link, &efi_mem);
+       /* Insert before current entry (descending address order) */
+       list_add_tail(&newmap->link, &map->link);
 
        /* Shrink the map to [ map_start ... carve_start ] */
        map_desc->num_pages = (carve_start - map_start) >> EFI_PAGE_SHIFT;