efi/libstub: smbios: Use length member instead of record struct size
authorArd Biesheuvel <ardb@kernel.org>
Tue, 28 Feb 2023 18:23:09 +0000 (19:23 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Sat, 18 Mar 2023 10:37:56 +0000 (11:37 +0100)
The type 1 SMBIOS record happens to always be the same size, but there
are other record types which have been augmented over time, and so we
should really use the length field in the header to decide where the
string table starts.

Fixes: 550b33cfd4452968 ("arm64: efi: Force the use of ...")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/smbios.c

index 460418b7f5f5e9ab1d721ec096eaa77bb2462c58..aadb422b9637dfc0b9b4e2960f79c6b45b462a3d 100644 (file)
@@ -36,7 +36,7 @@ const u8 *__efi_get_smbios_string(u8 type, int offset, int recsize)
        if (status != EFI_SUCCESS)
                return NULL;
 
-       strtable = (u8 *)record + recsize;
+       strtable = (u8 *)record + record->length;
        for (int i = 1; i < ((u8 *)record)[offset]; i++) {
                int len = strlen(strtable);