]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_driver: fix duplicate efiblk#0 issue
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Mon, 3 Jul 2023 06:08:45 +0000 (15:08 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 20 Jul 2023 07:12:50 +0000 (09:12 +0200)
The devnum value of the blk_desc structure starts from 0,
current efi_bl_create_block_device() function creates
two "efiblk#0" devices for the cases that blk_find_max_devnum()
returns -ENODEV and blk_find_max_devnum() returns 0(one device
found in this case).

This commit uses blk_next_free_devnum() instead of blk_find_max_devnum().

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_driver/efi_block_device.c

index add00eeebbea613d092dd17fe22704541d99fb85..e3abd90275c8200824ff761d5bdebca4ad7792e4 100644 (file)
@@ -124,10 +124,8 @@ efi_bl_create_block_device(efi_handle_t handle, void *interface)
        struct efi_block_io *io = interface;
        struct efi_blk_plat *plat;
 
-       devnum = blk_find_max_devnum(UCLASS_EFI_LOADER);
-       if (devnum == -ENODEV)
-               devnum = 0;
-       else if (devnum < 0)
+       devnum = blk_next_free_devnum(UCLASS_EFI_LOADER);
+       if (devnum < 0)
                return EFI_OUT_OF_RESOURCES;
 
        name = calloc(1, 18); /* strlen("efiblk#2147483648") + 1 */