From 9a9d21f780805fd6f950e930eeae437748d72793 Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Tue, 24 Feb 2026 00:33:42 +0100 Subject: [PATCH] Bluetooth: btintel_pcie: Use struct_size to improve hci_drv_read_info Use struct_size(), which provides additional compile-time checks for structures with flexible array members (e.g., __must_be_array()), to determine the allocation size for a new 'struct hci_drv_rp_read_info'. Signed-off-by: Thorsten Blum Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btintel_pcie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c index eda243988cfd..473b2115e637 100644 --- a/drivers/bluetooth/btintel_pcie.c +++ b/drivers/bluetooth/btintel_pcie.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -2373,7 +2374,7 @@ static int btintel_pcie_hci_drv_read_info(struct hci_dev *hdev, void *data, u16 opcode, num_supported_commands = ARRAY_SIZE(btintel_pcie_hci_drv_supported_commands); - rp_size = sizeof(*rp) + num_supported_commands * 2; + rp_size = struct_size(rp, supported_commands, num_supported_commands); rp = kmalloc(rp_size, GFP_KERNEL); if (!rp)