From e798c70719f5202734afe841ded91ea8e0a9d30f Mon Sep 17 00:00:00 2001 From: Frederic Dalleau Date: Thu, 25 Jul 2019 03:27:31 +0000 Subject: [PATCH] UPSTREAM: Bluetooth: Fix memory leak at end of hci requests In hci_req_sync_complete the event skb is referenced in hdev->req_skb. It is used (via hci_req_run_skb) from either __hci_cmd_sync_ev which will pass the skb to the caller, or __hci_req_sync which leaks. unreferenced object 0xffff880005339a00 (size 256): comm "kworker/u3:1", pid 1011, jiffies 4294671976 (age 107.389s) backtrace: [] kmemleak_alloc+0x49/0xa0 [] kmem_cache_alloc+0x128/0x180 [] skb_clone+0x4f/0xa0 [] hci_event_packet+0xc1/0x3290 [] hci_rx_work+0x18b/0x360 [] process_one_work+0x14a/0x440 [] worker_thread+0x43/0x4d0 [] kthread+0xc4/0xe0 [] ret_from_fork+0x1f/0x40 [] 0xffffffffffffffff Signed-off-by: Frederic Dalleau Signed-off-by: Marcel Holtmann Change-Id: Ic74b37024f9a291a94770461eb20a00701f21bf5 Signed-off-by: Yao Xiao (cherry picked from commit 9afee94939e3eda4c8bf239f7727cb56e158c976) --- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5d0b1358c754..3e2bb20813f7 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -357,6 +357,8 @@ static int __hci_req_sync(struct hci_dev *hdev, break; } + kfree_skb(hdev->req_skb); + hdev->req_skb = NULL; hdev->req_status = hdev->req_result = 0; BT_DBG("%s end: err %d", hdev->name, err);