[PATCH] Bluetooth: msft: fix null pointer deref on msft_monitor_device_evt

From: Soenke Huster
Date: Sat Jan 22 2022 - 03:37:56 EST


msft_find_handle_data returns NULL if it can't find the handle.
Therefore, handle_data must be checked, otherwise a null pointer
is dereferenced.

Signed-off-by: Soenke Huster <soenke.huster@xxxxxxxxx>
---
net/bluetooth/msft.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 484540855863..d2cf92e834f7 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -705,6 +705,9 @@ static void msft_monitor_device_evt(struct hci_dev *hdev, struct sk_buff *skb)

handle_data = msft_find_handle_data(hdev, ev->monitor_handle, false);

+ if (!handle_data)
+ return;
+
switch (ev->addr_type) {
case ADDR_LE_DEV_PUBLIC:
addr_type = BDADDR_LE_PUBLIC;
--
2.34.1