Lee, Chun-Yi a0130b
From: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
Lee, Chun-Yi a0130b
Date: Tue, 7 Jun 2022 23:30:20 +0800
Lee, Chun-Yi a0130b
Subject: Bluetooth: use memset avoid memory leaks
Lee, Chun-Yi a0130b
Patch-mainline: v6.0-rc1
Lee, Chun-Yi a0130b
Git-commit: a5133fe87ed827ce94084eecb7830a6d451ef55c
Lee, Chun-Yi a0130b
References: jsc#PED-1407
Lee, Chun-Yi a0130b
Lee, Chun-Yi a0130b
Similar to the handling of l2cap_ecred_connect in commit d3715b2333e9
Lee, Chun-Yi a0130b
("Bluetooth: use memset avoid memory leaks"), we thought a patch
Lee, Chun-Yi a0130b
might be needed here as well.
Lee, Chun-Yi a0130b
Lee, Chun-Yi a0130b
Use memset to initialize structs to prevent memory leaks
Lee, Chun-Yi a0130b
in l2cap_le_connect
Lee, Chun-Yi a0130b
Lee, Chun-Yi a0130b
Signed-off-by: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
Lee, Chun-Yi a0130b
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Lee, Chun-Yi a0130b
Acked-by: Lee, Chun-Yi <jlee@suse.com>
Lee, Chun-Yi a0130b
---
Lee, Chun-Yi a0130b
 net/bluetooth/l2cap_core.c |    1 +
Lee, Chun-Yi a0130b
 1 file changed, 1 insertion(+)
Lee, Chun-Yi a0130b
Lee, Chun-Yi a0130b
--- a/net/bluetooth/l2cap_core.c
Lee, Chun-Yi a0130b
+++ b/net/bluetooth/l2cap_core.c
Lee, Chun-Yi a0130b
@@ -1392,6 +1392,7 @@ static void l2cap_le_connect(struct l2ca
Lee, Chun-Yi a0130b
 
Lee, Chun-Yi a0130b
 	l2cap_le_flowctl_init(chan, 0);
Lee, Chun-Yi a0130b
 
Lee, Chun-Yi a0130b
+	memset(&req, 0, sizeof(req));
Lee, Chun-Yi a0130b
 	req.psm     = chan->psm;
Lee, Chun-Yi a0130b
 	req.scid    = cpu_to_le16(chan->scid);
Lee, Chun-Yi a0130b
 	req.mtu     = cpu_to_le16(chan->imtu);