Skip to content

Commit 6f7cf13

Browse files
gitcomit8Vudentz
authored andcommitted
drivers/bluetooth: btbcm: Use kmalloc_array() to prevent overflow
Replace the open-coded multiplication in kmalloc() with a call to kmalloc_array() to prevent potential integer overflows. This is a mechanical change, replacing BCM_FW_NAME_LEN with the type-safe sizeof(*fw_name) as the element size Signed-off-by: Ayaan Mirza Baig <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent bc6f557 commit 6f7cf13

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/bluetooth/btbcm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud
642642
snprintf(postfix, sizeof(postfix), "-%4.4x-%4.4x", vid, pid);
643643
}
644644

645-
fw_name = kmalloc(BCM_FW_NAME_COUNT_MAX * BCM_FW_NAME_LEN, GFP_KERNEL);
645+
fw_name = kmalloc_array(BCM_FW_NAME_COUNT_MAX,
646+
sizeof(*fw_name),
647+
GFP_KERNEL);
646648
if (!fw_name)
647649
return -ENOMEM;
648650

0 commit comments

Comments
 (0)