diff mbox series

Bluetooth: msft: fix null pointer deref on msft_monitor_device_evt

Message ID 20220122082751.285478-1-soenke.huster@eknoes.de (mailing list archive)
State Superseded
Headers show
Series Bluetooth: msft: fix null pointer deref on msft_monitor_device_evt | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/subjectprefix success PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/buildkernel32 success Build Kernel32 PASS
tedd_an/incremental_build success Pass
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 493, Passed: 493 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Soenke Huster Jan. 22, 2022, 8:27 a.m. UTC
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@eknoes.de>
---
 net/bluetooth/msft.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

bluez.test.bot@gmail.com Jan. 22, 2022, 9:04 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=607456

---Test result---

Test Summary:
CheckPatch                    PASS      1.69 seconds
GitLint                       PASS      0.98 seconds
SubjectPrefix                 PASS      0.87 seconds
BuildKernel                   PASS      35.09 seconds
BuildKernel32                 PASS      30.74 seconds
Incremental Build with patchesPASS      41.41 seconds
TestRunner: Setup             PASS      540.82 seconds
TestRunner: l2cap-tester      PASS      15.14 seconds
TestRunner: bnep-tester       PASS      6.82 seconds
TestRunner: mgmt-tester       PASS      115.33 seconds
TestRunner: rfcomm-tester     PASS      8.59 seconds
TestRunner: sco-tester        PASS      8.86 seconds
TestRunner: smp-tester        PASS      8.68 seconds
TestRunner: userchan-tester   PASS      7.10 seconds



---
Regards,
Linux Bluetooth
Marcel Holtmann Jan. 22, 2022, 9:39 p.m. UTC | #2
Hi Soenke,

> 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@eknoes.de>
> ---
> 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);
> 

scrap this empty line. The check can got right after the assignment.

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

Regards

Marcel
diff mbox series

Patch

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;