* [PATCH v2] Bluetooth: Fix memory leak at end of hci requests
@ 2016-08-23 5:59 Frédéric Dalleau
2016-08-24 14:57 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Frédéric Dalleau @ 2016-08-23 5:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frederic Dalleau
From: Frederic Dalleau <frederic.dalleau@collabora.co.uk>
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:
[<ffffffff818d89d9>] kmemleak_alloc+0x49/0xa0
[<ffffffff8116bba8>] kmem_cache_alloc+0x128/0x180
[<ffffffff8167c1df>] skb_clone+0x4f/0xa0
[<ffffffff817aa351>] hci_event_packet+0xc1/0x3290
[<ffffffff8179a57b>] hci_rx_work+0x18b/0x360
[<ffffffff810692ea>] process_one_work+0x14a/0x440
[<ffffffff81069623>] worker_thread+0x43/0x4d0
[<ffffffff8106ead4>] kthread+0xc4/0xe0
[<ffffffff818dd38f>] ret_from_fork+0x1f/0x40
[<ffffffffffffffff>] 0xffffffffffffffff
Signed-off-by: Frédéric Dalleau <frederic.dalleau@collabora.co.uk>
---
net/bluetooth/hci_request.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index c045b3c..b0e23df 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -262,6 +262,8 @@ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
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);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Bluetooth: Fix memory leak at end of hci requests
2016-08-23 5:59 [PATCH v2] Bluetooth: Fix memory leak at end of hci requests Frédéric Dalleau
@ 2016-08-24 14:57 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2016-08-24 14:57 UTC (permalink / raw)
To: Frédéric Dalleau; +Cc: linux-bluetooth
Hi Fred,
> 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:
> [<ffffffff818d89d9>] kmemleak_alloc+0x49/0xa0
> [<ffffffff8116bba8>] kmem_cache_alloc+0x128/0x180
> [<ffffffff8167c1df>] skb_clone+0x4f/0xa0
> [<ffffffff817aa351>] hci_event_packet+0xc1/0x3290
> [<ffffffff8179a57b>] hci_rx_work+0x18b/0x360
> [<ffffffff810692ea>] process_one_work+0x14a/0x440
> [<ffffffff81069623>] worker_thread+0x43/0x4d0
> [<ffffffff8106ead4>] kthread+0xc4/0xe0
> [<ffffffff818dd38f>] ret_from_fork+0x1f/0x40
> [<ffffffffffffffff>] 0xffffffffffffffff
>
> Signed-off-by: Frédéric Dalleau <frederic.dalleau@collabora.co.uk>
> ---
> net/bluetooth/hci_request.c | 2 ++
> 1 file changed, 2 insertions(+)
patch has been applied to bluetooth-stable tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-24 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-23 5:59 [PATCH v2] Bluetooth: Fix memory leak at end of hci requests Frédéric Dalleau
2016-08-24 14:57 ` Marcel Holtmann
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).