]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: memory leak in efi_set_bootdev()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 16 Sep 2018 05:20:21 +0000 (07:20 +0200)
committerAlexander Graf <agraf@suse.de>
Sun, 23 Sep 2018 19:55:30 +0000 (21:55 +0200)
efi_set_bootdev() may be called repeatedly.
Free the memory allocated for device paths in previous calls.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
cmd/bootefi.c

index d6366c3e26d43731dee27b7c45afe882a2c8d0b8..c8812b0f5e29bfe8f0035e7ade3a3317b6324b1d 100644 (file)
@@ -603,6 +603,13 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
        char filename[32] = { 0 }; /* dp->str is u16[32] long */
        char *s;
 
+       /* efi_set_bootdev is typically called repeatedly, recover memory */
+       efi_free_pool(bootefi_device_path);
+       efi_free_pool(bootefi_image_path);
+       /* If blk_get_device_part_str fails, avoid duplicate free. */
+       bootefi_device_path = NULL;
+       bootefi_image_path = NULL;
+
        if (strcmp(dev, "Net")) {
                struct blk_desc *desc;
                disk_partition_t fs_partition;