Skip to content

Commit fedbe19

Browse files
rickywu0421opsiff
authored andcommitted
FROMLIST: Bluetooth: btusb: Add NULL check for data in btusb_suspend
When performing warm boot tests with an MT7920 device, we encounter NULL pointer dereferences with failure rate 5/30. The crash occurs during device suspend when btusb attempts to access data->hdev where data is NULL. This may happen due to a race condition between PM suspend and device disconnect. The root cause needs further investigation. BUG: kernel NULL pointer dereference, address: 0000000000000000 Workqueue: pm pm_runtime_work RIP: 0010:btusb_suspend+0x1d/0x1d0 [btusb] Add a NULL check for data and return -ENODEV in this case to prevent the NULL pointer dereference. This indicates that the device is no longer available, which is appropriate when the driver's private data is missing. Signed-off-by: En-Wei Wu <en-wei.wu@canonical.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 5c62e9f commit fedbe19

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/bluetooth/btusb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4075,6 +4075,9 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
40754075

40764076
BT_DBG("intf %p", intf);
40774077

4078+
if (!data)
4079+
return -ENODEV;
4080+
40784081
/* Don't auto-suspend if there are connections; external suspend calls
40794082
* shall never fail.
40804083
*/

0 commit comments

Comments
 (0)