Skip to content

Commit aef2aa4

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: hci_event: Fix creating hci_conn object on error status
It is useless to create a hci_conn object if on error status as the result would be it being freed in the process and anyway it is likely the result of controller and host stack being out of sync. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent c86cc5a commit aef2aa4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/bluetooth/hci_event.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,12 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
30753075

30763076
conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
30773077
if (!conn) {
3078+
/* In case of error status and there is no connection pending
3079+
* just unlock as there is nothing to cleanup.
3080+
*/
3081+
if (ev->status)
3082+
goto unlock;
3083+
30783084
/* Connection may not exist if auto-connected. Check the bredr
30793085
* allowlist to see if this device is allowed to auto connect.
30803086
* If link is an ACL type, create a connection class
@@ -5542,6 +5548,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
55425548

55435549
conn = hci_lookup_le_connect(hdev);
55445550
if (!conn) {
5551+
/* In case of error status and there is no connection pending
5552+
* just unlock as there is nothing to cleanup.
5553+
*/
5554+
if (status)
5555+
goto unlock;
5556+
55455557
conn = hci_conn_add(hdev, LE_LINK, bdaddr, role);
55465558
if (!conn) {
55475559
bt_dev_err(hdev, "no memory for new connection");

0 commit comments

Comments
 (0)