]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: memory leak efi_add_memory_map_pg
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 30 Jul 2023 10:59:32 +0000 (12:59 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 3 Aug 2023 07:21:02 +0000 (09:21 +0200)
Don't leak newlist if we error out.

Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_memory.c

index 45d3bf52b8a4ae3e71331ea0ea76ec6e151d9aa4..ebf4a2d5fa3a1ac52f55889480bb8a8c5f5a7746 100644 (file)
@@ -324,6 +324,7 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
                                 * The user requested to only have RAM overlaps,
                                 * but we hit a non-RAM region. Error out.
                                 */
+                               free(newlist);
                                return EFI_NO_MAPPING;
                        case EFI_CARVE_NO_OVERLAP:
                                /* Just ignore this list entry */
@@ -354,6 +355,7 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
                 * The payload wanted to have RAM overlaps, but we overlapped
                 * with an unallocated region. Error out.
                 */
+               free(newlist);
                return EFI_NO_MAPPING;
        }