]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: efi_disk_register() should not fail
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 20 Nov 2021 12:56:02 +0000 (13:56 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 26 Nov 2021 20:30:59 +0000 (21:30 +0100)
Our algorithm for creating USB device paths may lead to duplicate device
paths which result in efi_disk_register() failing. Instead we should just
skip devices that cannot be registered as EFI block devices.

Fix a memory leak in efi_disk_add_dev() caused by the duplicate device
path.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/efi_disk.c

index ef8b5c88ff9db1a17ec6cecfaa6d6dc1a49f6822..45127d176869fc4eff10504f0e14ab1b496bdb15 100644 (file)
@@ -424,7 +424,7 @@ static efi_status_t efi_disk_add_dev(
                        &efi_block_io_guid, &diskobj->ops,
                        guid, NULL, NULL));
        if (ret != EFI_SUCCESS)
-               return ret;
+               goto error;
 
        /*
         * On partitions or whole disks without partitions install the
@@ -573,7 +573,7 @@ efi_status_t efi_disk_register(void)
                if (ret) {
                        log_err("ERROR: failure to add disk device %s, r = %lu\n",
                                dev->name, ret & ~EFI_ERROR_MASK);
-                       return ret;
+                       continue;
                }
                disks++;