Skip to contentSkip to conversation

Bug in net/bluetooth/a2mp.c

DISCUSSION Schmid, Carsten 1 participant 2 messages Jan 13, 2021 1 message not in the archive Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi Marcel, Luis,

i just backported your patch
eddb7732119d53400f48a02536a84c509692faa8 Bluetooth: A2MP: Fix not initializing all members into our project kernel, and a reviewer has found a bug:

@@ -376,6 +383,8 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
struct a2mp_amp_assoc_rsp rsp;
rsp.id = req->id;

+memset(&rsp, 0, sizeof(rsp));
+
if (tmp) {
rsp.status = A2MP_STATUS_COLLISION_OCCURED;
amp_mgr_put(tmp);

Here, rsp.id is set to req->id but then zeroed with memset.

Two hunks above in the same patch this is done in reverse order:
@@ -305,6 +308,8 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
if (!hdev || hdev->dev_type != HCI_AMP) {
struct a2mp_info_rsp rsp;

+memset(&rsp, 0, sizeof(rsp));
+
rsp.id = req->id;
rsp.status = A2MP_STATUS_INVALID_CTRL_ID;

I assume this is the correct way.
Could this lead to bluetooth malfunctioning, and needs to be patched? Shall i prepare a patch?

Best regards
Carsten
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

#2 lore raw
In reply to a message not in the archive
Quoted 1 line

Yes. I submitted a patch that corrects this, and it has already been accepted into bluetooth-next. It has not made it into any kernels yet.

Thanks for notifying me.

BR
Carsten
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter