Skip to content

Commit 201b5c0

Browse files
committed
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
2 parents 7e57714 + 258dd90 commit 201b5c0

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

drivers/firmware/efi/libstub/riscv-stub.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,34 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long);
2525

2626
static u32 hartid;
2727

28-
static u32 get_boot_hartid_from_fdt(void)
28+
static int get_boot_hartid_from_fdt(void)
2929
{
3030
const void *fdt;
3131
int chosen_node, len;
3232
const fdt32_t *prop;
3333

3434
fdt = get_efi_config_table(DEVICE_TREE_GUID);
3535
if (!fdt)
36-
return U32_MAX;
36+
return -EINVAL;
3737

3838
chosen_node = fdt_path_offset(fdt, "/chosen");
3939
if (chosen_node < 0)
40-
return U32_MAX;
40+
return -EINVAL;
4141

4242
prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len);
4343
if (!prop || len != sizeof(u32))
44-
return U32_MAX;
44+
return -EINVAL;
4545

46-
return fdt32_to_cpu(*prop);
46+
hartid = fdt32_to_cpu(*prop);
47+
return 0;
4748
}
4849

4950
efi_status_t check_platform_features(void)
5051
{
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) {
5356
efi_err("/chosen/boot-hartid missing or invalid!\n");
5457
return EFI_UNSUPPORTED;
5558
}

drivers/firmware/efi/vars.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
742742
{
743743
const struct efivar_operations *ops;
744744
efi_status_t status;
745+
unsigned long varsize;
745746

746747
if (!__efivars)
747748
return -EINVAL;
@@ -764,15 +765,17 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
764765
return efivar_entry_set_nonblocking(name, vendor, attributes,
765766
size, data);
766767

768+
varsize = size + ucs2_strsize(name, 1024);
767769
if (!block) {
768770
if (down_trylock(&efivars_lock))
769771
return -EBUSY;
772+
status = check_var_size_nonblocking(attributes, varsize);
770773
} else {
771774
if (down_interruptible(&efivars_lock))
772775
return -EINTR;
776+
status = check_var_size(attributes, varsize);
773777
}
774778

775-
status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
776779
if (status != EFI_SUCCESS) {
777780
up(&efivars_lock);
778781
return -ENOSPC;

0 commit comments

Comments
 (0)