efistub/x86: Use struct_size() in preserve_pci_rom_image()
PATCH 1/1 efistub/x86: Use struct_size() in preserve_pci_rom_image()
Use struct_size(), which provides additional compile-time checks for structures with flexible array members (e.g., __must_be_array()), to determine the ROM allocation size.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/firmware/efi/libstub/x86-stub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/firmware/efi/libstub/x86-stub.c +2 -1
@@ -7,6 +7,7 @@* ----------------------------------------------------------------------- */ #include <linux/efi.h> +#include <linux/overflow.h> #include <linux/pci.h> #include <linux/stddef.h>
@@ -62,7 +63,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)if (!romimage || !romsize || romsize >SZ_16M )return EFI_INVALID_PARAMETER ; - size = romsize +sizeof (*rom); + size =struct_size (rom, romdata, romsize); status =efi_bs_call (allocate_pool,EFI_LOADER_DATA , size, (void **)&rom);
Thorsten Blum <[email protected]> writes:
Hello Thorsten,
Quoted 6 lines
Use
struct_size(), which provides additional compile-time checks for structures with flexible array members (e.g.,__must_be_array()), to determine the ROM allocation size.Signed-off-by Thorsten Blum <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat