From: Zhongqiu Han Date: Sat, 5 Jul 2025 10:52:46 +0000 (+0800) Subject: Bluetooth: btusb: Fix potential NULL dereference on kmalloc failure X-Git-Tag: io_uring-6.17-20250815~128^2~31^2~23 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b505902c66a282dcb01bcdc015aa1fdfaaa075db;p=linux-block.git 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: 7d70989fcea7 ("Bluetooth: btusb: Add HCI Drv commands for configuring altsetting") Signed-off-by: Zhongqiu Han Signed-off-by: Luiz Augusto von Dentz --- diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index b04a4ad64e3b..8023a2eb4681 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3809,6 +3809,8 @@ static int btusb_hci_drv_supported_altsettings(struct hci_dev *hdev, void *data, /* There are at most 7 alt (0 - 6) */ rp = kmalloc(sizeof(*rp) + 7, GFP_KERNEL); + if (!rp) + return -ENOMEM; rp->num = 0; if (!drvdata->isoc)