Skip to content

Commit

Permalink
efi_loader: Do not leak memory when unlinking a mapping
Browse files Browse the repository at this point in the history
As soon as a mapping is unlinked from the list, there are no further
references to it, so it should be freed. If it not unlinked,
update the start address and length.

Signed-off-by: Stefan Brüns <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
  • Loading branch information
StefanBruens authored and agraf committed Oct 18, 2016
1 parent b6a9517 commit 511d0b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/efi_loader/efi_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
if (map_end == carve_end) {
/* Full overlap, just remove map */
list_del(&map->link);
free(map);
} else {
map->desc.physical_start = carve_end;
map->desc.num_pages = (map_end - carve_end)
>> EFI_PAGE_SHIFT;
}

map_desc->physical_start = carve_end;
map_desc->num_pages = (map_end - carve_end) >> EFI_PAGE_SHIFT;
return (carve_end - carve_start) >> EFI_PAGE_SHIFT;
}

Expand Down

0 comments on commit 511d0b9

Please sign in to comment.