All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Add NULL check for data in btusb_suspend
@ 2024-12-20  8:22 En-Wei Wu
  2024-12-20  8:50 ` [PATCH] Bluetooth: btusb: Add NULL check for data in btusb_suspend() Markus Elfring
  2024-12-20  8:59 ` Bluetooth: btusb: Add NULL check for data in btusb_suspend bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: En-Wei Wu @ 2024-12-20  8:22 UTC (permalink / raw)
  To: marcel, luiz.dentz, linux-bluetooth, linux-kernel

When performing warm boot tests with an MT7920 device,
we encounter NULL pointer dereference 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>
---
 drivers/bluetooth/btusb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 279fe6c115fa..a0461528548b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4096,6 +4096,9 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
 
 	BT_DBG("intf %p", intf);
 
+	if (!data)
+		return -ENODEV;
+
 	/* Don't auto-suspend if there are connections; external suspend calls
 	 * shall never fail.
 	 */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH v2] Bluetooth: btusb: Add NULL check for data in btusb_suspend
@ 2024-12-23  9:44 En-Wei Wu
  2024-12-31  9:05 ` Wentao Guan
  0 siblings, 1 reply; 4+ messages in thread
From: En-Wei Wu @ 2024-12-23  9:44 UTC (permalink / raw)
  To: marcel, luiz.dentz, linux-bluetooth, linux-kernel; +Cc: Markus.Elfring

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>
---
Changes in v2:
- Change "dereference" to "dereferences" in commit message
- Re-flow commit message lines to use more characters per line

 drivers/bluetooth/btusb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 279fe6c115fa..a0461528548b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4096,6 +4096,9 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
 
 	BT_DBG("intf %p", intf);
 
+	if (!data)
+		return -ENODEV;
+
 	/* Don't auto-suspend if there are connections; external suspend calls
 	 * shall never fail.
 	 */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-31  9:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20  8:22 [PATCH] Bluetooth: btusb: Add NULL check for data in btusb_suspend En-Wei Wu
2024-12-20  8:50 ` [PATCH] Bluetooth: btusb: Add NULL check for data in btusb_suspend() Markus Elfring
2024-12-20  8:59 ` Bluetooth: btusb: Add NULL check for data in btusb_suspend bluez.test.bot
  -- strict thread matches above, loose matches on Subject: below --
2024-12-23  9:44 [PATCH v2] " En-Wei Wu
2024-12-31  9:05 ` Wentao Guan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.