From: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
To: marcel@holtmann.org, johan.hedberg@gmail.com, davem@davemloft.net
Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] Bluetooth: fix kernel null pointer dereference error on suspend
Date: Mon, 29 Jun 2020 19:56:03 +0530 [thread overview]
Message-ID: <20200629142600.GA3102@cosmos> (raw)
BUG Call Trace:
queue_work_on+0x39/0x40
hci_adv_monitors_clear+0x71/0x90 [bluetooth]
hci_unregister_dev+0x18a/0x2f0 [bluetooth]
btusb_disconnect+0x68/0x150 [btusb]
usb_unbind_interface+0x7f/0x260
device_release_driver_internal+0xec/0x1b0
device_release_driver+0x12/0x20
bus_remove_device+0xe1/0x150
device_del+0x17d/0x3e0
usb_disable_device+0x9f/0x250
usb_disconnect+0xc6/0x270
hub_event+0x6da/0x18d0
process_one_work+0x20c/0x400
worker_thread+0x34/0x400
RIP: 0010:__queue_work+0x92/0x3f0
NULL deference occurs in hci_update_background_scan() while it tries
to queue_work on already destroyed workqueues.
Change hci_unregister_dev() to invoke destroy_workqueues after the
call to hci_adv_monitors_clear().
Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
---
net/bluetooth/hci_core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 7959b85..5577cf9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3795,9 +3795,6 @@ void hci_unregister_dev(struct hci_dev *hdev)
kfree_const(hdev->hw_info);
kfree_const(hdev->fw_info);
- destroy_workqueue(hdev->workqueue);
- destroy_workqueue(hdev->req_workqueue);
-
hci_dev_lock(hdev);
hci_bdaddr_list_clear(&hdev->blacklist);
hci_bdaddr_list_clear(&hdev->whitelist);
@@ -3815,6 +3812,9 @@ void hci_unregister_dev(struct hci_dev *hdev)
hci_blocked_keys_clear(hdev);
hci_dev_unlock(hdev);
+ destroy_workqueue(hdev->workqueue);
+ destroy_workqueue(hdev->req_workqueue);
+
hci_dev_put(hdev);
ida_simple_remove(&hci_index_ida, id);
--
2.7.4
next reply other threads:[~2020-06-29 20:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 14:26 Vamshi K Sthambamkadi [this message]
2020-06-29 15:42 ` [PATCH] Bluetooth: fix kernel null pointer dereference error on suspend Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200629142600.GA3102@cosmos \
--to=vamshi.k.sthambamkadi@gmail.com \
--cc=davem@davemloft.net \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).