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
3075 3075
3076 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);3076 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
3077 if (!conn) {3077 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
3078 /* Connection may not exist if auto-connected. Check the bredr3084 /* Connection may not exist if auto-connected. Check the bredr
3079 * allowlist to see if this device is allowed to auto connect.3085 * allowlist to see if this device is allowed to auto connect.
3080 * If link is an ACL type, create a connection class3086 * 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
5542 5548
5543 conn = hci_lookup_le_connect(hdev);5549 conn = hci_lookup_le_connect(hdev);
5544 if (!conn) {5550 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
5545 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role);5557 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role);
5546 if (!conn) {5558 if (!conn) {
5547 bt_dev_err(hdev, "no memory for new connection");5559 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