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 <thorsten.blum@linux.dev>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/firmware.h>
+#include <linux/overflow.h>
#include <linux/pci.h>
#include <linux/string.h>
#include <linux/wait.h>
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)