History

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.

Luiz Augusto von Dentz committed 4 years ago

Commit aef2aa41 parent c86cc5a1 file · +12 −0Browse files

Unified · Split

net/bluetooth/hci_event.c+12−0
@@ -3075,6 +3075,12 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, · 3074 unmodified lines
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, · 2461 unmodified lines
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");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t