[PATCH] Bluetooth: use memset avoid memory leaks

Gongwei Li posted 1 patch 3 months ago
net/bluetooth/l2cap_core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] Bluetooth: use memset avoid memory leaks
Posted by Gongwei Li 3 months ago
From: Gongwei Li <ligongwei@kylinos.cn>

Similar to the handling of l2cap_le_connect in commit a5133fe87ed8
("Bluetooth: use memset avoid memory leaks"), we thought a patch
might be needed here as well.

Use memset to initialize structs to prevent memory leaks
in __l2cap_le_connect_rsp_defer.

Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>
---
 net/bluetooth/l2cap_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d08320380..b987ba5de 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3786,6 +3786,7 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan)
 
 	BT_DBG("chan %p", chan);
 
+	memset(&rsp, 0, sizeof(rsp));
 	rsp.dcid    = cpu_to_le16(chan->scid);
 	rsp.mtu     = cpu_to_le16(chan->imtu);
 	rsp.mps     = cpu_to_le16(chan->mps);
-- 
2.25.1