mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efistub/x86: Use struct_size() in preserve_pci_rom_image()
@ 2026-11-08 15:28 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-11-08 15:28 UTC (permalink / raw)
  To: Ard Biesheuvel, Ilias Apalodimas, Vincent Mailhol,
	Thomas Zimmermann, Javier Martinez Canillas, Thorsten Blum
  Cc: linux-efi, linux-kernel

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 <blum@kernel.org>
---
 drivers/firmware/efi/libstub/x86-stub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 253dd3ba8fab..5d35cfe78775 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-08 15:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 15:28 [PATCH] efistub/x86: Use struct_size() in preserve_pci_rom_image() Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®