summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongqiu Han <quic_zhonhan@quicinc.com>2025-07-05 18:52:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-15 16:38:51 +0200
commit5029d80bfc30b60ff57c70ccb04e027acb404f6a (patch)
treedbc8b66140dd56bb768e784498ea44adc844f838
parent615dfc9acd35da56f33929ae20fe87752b80b2bc (diff)
Bluetooth: btusb: Fix potential NULL dereference on kmalloc failure
[ Upstream commit b505902c66a282dcb01bcdc015aa1fdfaaa075db ] 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 <quic_zhonhan@quicinc.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/bluetooth/btusb.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f9eeec0aed57..db27d28e8a7e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3802,6 +3802,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)