]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: btusb: Fix potential NULL dereference on kmalloc failure
authorZhongqiu Han <quic_zhonhan@quicinc.com>
Sat, 5 Jul 2025 10:52:46 +0000 (18:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:38:51 +0000 (16:38 +0200)
[ 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>
drivers/bluetooth/btusb.c

index f9eeec0aed57dae4a1c589c9cc83a6407e174832..db27d28e8a7ee295d31b3953fa899ea9e057c74c 100644 (file)
@@ -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)