Skip to content

Commit b505902

Browse files
ZhongqiuHan-QcomVudentz
authored andcommitted
Bluetooth: btusb: Fix potential NULL dereference on kmalloc failure
Avoid potential NULL pointer dereference by checking the return value of kmalloc and handling allocation failure properly. Fixes: 7d70989 ("Bluetooth: btusb: Add HCI Drv commands for configuring altsetting") Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 636c803 commit b505902

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/bluetooth/btusb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,8 @@ static int btusb_hci_drv_supported_altsettings(struct hci_dev *hdev, void *data,
38093809

38103810
/* There are at most 7 alt (0 - 6) */
38113811
rp = kmalloc(sizeof(*rp) + 7, GFP_KERNEL);
3812+
if (!rp)
3813+
return -ENOMEM;
38123814

38133815
rp->num = 0;
38143816
if (!drvdata->isoc)

0 commit comments

Comments
 (0)