[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250705105246.1383084-1-quic_zhonhan@quicinc.com>
Date: Sat, 5 Jul 2025 18:52:46 +0800
From: Zhongqiu Han <quic_zhonhan@...cinc.com>
To: <marcel@...tmann.org>, <luiz.dentz@...il.com>, <chharry@...omium.org>
CC: <linux-bluetooth@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<quic_zhonhan@...cinc.com>
Subject: [PATCH] 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 <quic_zhonhan@...cinc.com>
---
drivers/bluetooth/btusb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f8f256ff79a3..642b3238ea39 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3799,6 +3799,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)
--
2.43.0
Powered by blists - more mailing lists