Skip to content

Commit 122414e

Browse files
Vudentzgregkh
authored andcommitted
Bluetooth: A2MP: Fix not initializing all members
commit eddb773 upstream. This fixes various places where a stack variable is used uninitialized. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bbf5c97 commit 122414e

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

net/bluetooth/a2mp.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
226226
struct a2mp_info_req req;
227227

228228
found = true;
229+
230+
memset(&req, 0, sizeof(req));
231+
229232
req.id = cl->id;
230233
a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr),
231234
sizeof(req), &req);
@@ -305,6 +308,8 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
305308
if (!hdev || hdev->dev_type != HCI_AMP) {
306309
struct a2mp_info_rsp rsp;
307310

311+
memset(&rsp, 0, sizeof(rsp));
312+
308313
rsp.id = req->id;
309314
rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
310315

@@ -348,6 +353,8 @@ static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
348353
if (!ctrl)
349354
return -ENOMEM;
350355

356+
memset(&req, 0, sizeof(req));
357+
351358
req.id = rsp->id;
352359
a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
353360
&req);
@@ -376,6 +383,8 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
376383
struct a2mp_amp_assoc_rsp rsp;
377384
rsp.id = req->id;
378385

386+
memset(&rsp, 0, sizeof(rsp));
387+
379388
if (tmp) {
380389
rsp.status = A2MP_STATUS_COLLISION_OCCURED;
381390
amp_mgr_put(tmp);
@@ -464,7 +473,6 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
464473
struct a2mp_cmd *hdr)
465474
{
466475
struct a2mp_physlink_req *req = (void *) skb->data;
467-
468476
struct a2mp_physlink_rsp rsp;
469477
struct hci_dev *hdev;
470478
struct hci_conn *hcon;
@@ -475,6 +483,8 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
475483

476484
BT_DBG("local_id %d, remote_id %d", req->local_id, req->remote_id);
477485

486+
memset(&rsp, 0, sizeof(rsp));
487+
478488
rsp.local_id = req->remote_id;
479489
rsp.remote_id = req->local_id;
480490

@@ -553,6 +563,8 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
553563

554564
BT_DBG("local_id %d remote_id %d", req->local_id, req->remote_id);
555565

566+
memset(&rsp, 0, sizeof(rsp));
567+
556568
rsp.local_id = req->remote_id;
557569
rsp.remote_id = req->local_id;
558570
rsp.status = A2MP_STATUS_SUCCESS;
@@ -675,6 +687,8 @@ static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
675687
if (err) {
676688
struct a2mp_cmd_rej rej;
677689

690+
memset(&rej, 0, sizeof(rej));
691+
678692
rej.reason = cpu_to_le16(0);
679693
hdr = (void *) skb->data;
680694

@@ -898,6 +912,8 @@ void a2mp_send_getinfo_rsp(struct hci_dev *hdev)
898912

899913
BT_DBG("%s mgr %p", hdev->name, mgr);
900914

915+
memset(&rsp, 0, sizeof(rsp));
916+
901917
rsp.id = hdev->id;
902918
rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
903919

@@ -995,6 +1011,8 @@ void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status)
9951011
if (!mgr)
9961012
return;
9971013

1014+
memset(&rsp, 0, sizeof(rsp));
1015+
9981016
hs_hcon = hci_conn_hash_lookup_state(hdev, AMP_LINK, BT_CONNECT);
9991017
if (!hs_hcon) {
10001018
rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION;
@@ -1027,6 +1045,8 @@ void a2mp_discover_amp(struct l2cap_chan *chan)
10271045

10281046
mgr->bredr_chan = chan;
10291047

1048+
memset(&req, 0, sizeof(req));
1049+
10301050
req.mtu = cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU);
10311051
req.ext_feat = 0;
10321052
a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req);

0 commit comments

Comments
 (0)