Skip to content

Commit b4066eb

Browse files
siddhpantVudentz
authored andcommitted
Bluetooth: hci_conn: return ERR_PTR instead of NULL when there is no link
hci_connect_sco currently returns NULL when there is no link (i.e. when hci_conn_link() returns NULL). sco_connect() expects an ERR_PTR in case of any error (see line 266 in sco.c). Thus, hcon set as NULL passes through to sco_conn_add(), which tries to get hcon->hdev, resulting in dereferencing a NULL pointer as reported by syzkaller. The same issue exists for iso_connect_cis() calling hci_connect_cis(). Thus, make hci_connect_sco() and hci_connect_cis() return ERR_PTR instead of NULL. Reported-and-tested-by: syzbot+37acd5d80d00d609d233@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=37acd5d80d00d609d233 Fixes: 0614974 ("Bluetooth: hci_conn: Add support for linking multiple hcon") Signed-off-by: Siddh Raman Pant <code@siddh.me> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent de6dfce commit b4066eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bluetooth/hci_conn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
16841684
if (!link) {
16851685
hci_conn_drop(acl);
16861686
hci_conn_drop(sco);
1687-
return NULL;
1687+
return ERR_PTR(-ENOLINK);
16881688
}
16891689

16901690
sco->setting = setting;
@@ -2254,7 +2254,7 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
22542254
if (!link) {
22552255
hci_conn_drop(le);
22562256
hci_conn_drop(cis);
2257-
return NULL;
2257+
return ERR_PTR(-ENOLINK);
22582258
}
22592259

22602260
/* If LE is already connected and CIS handle is already set proceed to

0 commit comments

Comments
 (0)