Bluetooth: btusb: fix memory leak on suspend and resume

Started by Vamshi K Sthambamkadi on Jan 14, 2021 · 2 messages from 2 authors · Last reply Jan 25, 2021

Subsystems (2)

Maintainers (3)

STALE2119d

open the first message on its own page

Message details and related content
kmemleak report:
unreferenced object 0xffff9b1127f00500 (size 208):
  comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 60 ed 05 11 9b ff ff 00 00 00 00 00 00 00 00  .`..............
  backtrace:
    [<000000006ab3fd59>] kmem_cache_alloc_node+0x17a/0x480
    [<0000000051a5f6f9>] __alloc_skb+0x5b/0x1d0
    [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
    [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
    [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
    [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
    [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
    [<000000002677dd79>] process_one_work+0x209/0x3b0
    [<00000000aaa62b07>] worker_thread+0x34/0x400
    [<00000000826d176c>] kthread+0x126/0x140
    [<000000002305e558>] ret_from_fork+0x22/0x30
unreferenced object 0xffff9b1125c6ee00 (size 512):
  comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
  hex dump (first 32 bytes):
    04 00 00 00 0d 00 00 00 05 0c 01 00 11 9b ff ff  ................
    00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000009f07c0cc>] slab_post_alloc_hook+0x59/0x270
    [<0000000049431dc2>] __kmalloc_node_track_caller+0x15f/0x330
    [<00000000027a42f6>] __kmalloc_reserve.isra.70+0x31/0x90
    [<00000000e8e3e76a>] __alloc_skb+0x87/0x1d0
    [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
    [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
    [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
    [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
    [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
    [<000000002677dd79>] process_one_work+0x209/0x3b0
    [<00000000aaa62b07>] worker_thread+0x34/0x400
    [<00000000826d176c>] kthread+0x126/0x140
    [<000000002305e558>] ret_from_fork+0x22/0x30
unreferenced object 0xffff9b112b395788 (size 8):
  comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
  hex dump (first 8 bytes):

71 more lines

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9d2c9a1c552f..1c793e6eb92a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3566,7 +3566,8 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action,
 	}
 
 	/* Suspend notifier should only act on events when powered. */
-	if (!hdev_is_powered(hdev))
+	if (!hdev_is_powered(hdev) ||
+	    hci_dev_test_flag(hdev, HCI_UNREGISTER))
 		goto done;
 
 	if (action == PM_SUSPEND_PREPARE) {
-- 
2.17.1
Message details and related content
Hi Vamshi,
kmemleak report:
unreferenced object 0xffff9b1127f00500 (size 208):
 comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
 hex dump (first 32 bytes):
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00 60 ed 05 11 9b ff ff 00 00 00 00 00 00 00 00  .`..............
 backtrace:
   [<000000006ab3fd59>] kmem_cache_alloc_node+0x17a/0x480
   [<0000000051a5f6f9>] __alloc_skb+0x5b/0x1d0
   [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
   [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
   [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
   [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
   [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
   [<000000002677dd79>] process_one_work+0x209/0x3b0
   [<00000000aaa62b07>] worker_thread+0x34/0x400
   [<00000000826d176c>] kthread+0x126/0x140
   [<000000002305e558>] ret_from_fork+0x22/0x30
unreferenced object 0xffff9b1125c6ee00 (size 512):
 comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
 hex dump (first 32 bytes):
   04 00 00 00 0d 00 00 00 05 0c 01 00 11 9b ff ff  ................
   00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
 backtrace:
   [<000000009f07c0cc>] slab_post_alloc_hook+0x59/0x270
   [<0000000049431dc2>] __kmalloc_node_track_caller+0x15f/0x330
   [<00000000027a42f6>] __kmalloc_reserve.isra.70+0x31/0x90
   [<00000000e8e3e76a>] __alloc_skb+0x87/0x1d0
   [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
   [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
   [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
   [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
   [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
   [<000000002677dd79>] process_one_work+0x209/0x3b0
   [<00000000aaa62b07>] worker_thread+0x34/0x400
   [<00000000826d176c>] kthread+0x126/0x140
   [<000000002305e558>] ret_from_fork+0x22/0x30
unreferenced object 0xffff9b112b395788 (size 8):
 comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
 hex dump (first 8 bytes):

70 more quoted lines

patch has been applied to bluetooth-next tree.

Regards

Marcel
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help