Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'efi-urgent-for-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fixes from Ard Biesheuvel:

- don't treat valid hartid U32_MAX as a failure return code (RISC-V)

- avoid blocking query_variable_info() call when blocking is not
allowed

* tag 'efi-urgent-for-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
efivars: Respect "block" flag in efivar_entry_set_safe()
riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value

+14 -8
+10 -7
drivers/firmware/efi/libstub/riscv-stub.c
··· 25 25 26 26 static u32 hartid; 27 27 28 - static u32 get_boot_hartid_from_fdt(void) 28 + static int get_boot_hartid_from_fdt(void) 29 29 { 30 30 const void *fdt; 31 31 int chosen_node, len; ··· 33 33 34 34 fdt = get_efi_config_table(DEVICE_TREE_GUID); 35 35 if (!fdt) 36 - return U32_MAX; 36 + return -EINVAL; 37 37 38 38 chosen_node = fdt_path_offset(fdt, "/chosen"); 39 39 if (chosen_node < 0) 40 - return U32_MAX; 40 + return -EINVAL; 41 41 42 42 prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len); 43 43 if (!prop || len != sizeof(u32)) 44 - return U32_MAX; 44 + return -EINVAL; 45 45 46 - return fdt32_to_cpu(*prop); 46 + hartid = fdt32_to_cpu(*prop); 47 + return 0; 47 48 } 48 49 49 50 efi_status_t check_platform_features(void) 50 51 { 51 - hartid = get_boot_hartid_from_fdt(); 52 - if (hartid == U32_MAX) { 52 + int ret; 53 + 54 + ret = get_boot_hartid_from_fdt(); 55 + if (ret) { 53 56 efi_err("/chosen/boot-hartid missing or invalid!\n"); 54 57 return EFI_UNSUPPORTED; 55 58 }
+4 -1
drivers/firmware/efi/vars.c
··· 742 742 { 743 743 const struct efivar_operations *ops; 744 744 efi_status_t status; 745 + unsigned long varsize; 745 746 746 747 if (!__efivars) 747 748 return -EINVAL; ··· 765 764 return efivar_entry_set_nonblocking(name, vendor, attributes, 766 765 size, data); 767 766 767 + varsize = size + ucs2_strsize(name, 1024); 768 768 if (!block) { 769 769 if (down_trylock(&efivars_lock)) 770 770 return -EBUSY; 771 + status = check_var_size_nonblocking(attributes, varsize); 771 772 } else { 772 773 if (down_interruptible(&efivars_lock)) 773 774 return -EINTR; 775 + status = check_var_size(attributes, varsize); 774 776 } 775 777 776 - status = check_var_size(attributes, size + ucs2_strsize(name, 1024)); 777 778 if (status != EFI_SUCCESS) { 778 779 up(&efivars_lock); 779 780 return -ENOSPC;