Commit aef2aa4f authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Marcel Holtmann

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: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent c86cc5a3
...@@ -3075,6 +3075,12 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, ...@@ -3075,6 +3075,12 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
if (!conn) { if (!conn) {
/* In case of error status and there is no connection pending
* just unlock as there is nothing to cleanup.
*/
if (ev->status)
goto unlock;
/* Connection may not exist if auto-connected. Check the bredr /* Connection may not exist if auto-connected. Check the bredr
* allowlist to see if this device is allowed to auto connect. * allowlist to see if this device is allowed to auto connect.
* If link is an ACL type, create a connection class * 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, ...@@ -5542,6 +5548,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
conn = hci_lookup_le_connect(hdev); conn = hci_lookup_le_connect(hdev);
if (!conn) { if (!conn) {
/* In case of error status and there is no connection pending
* just unlock as there is nothing to cleanup.
*/
if (status)
goto unlock;
conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); conn = hci_conn_add(hdev, LE_LINK, bdaddr, role);
if (!conn) { if (!conn) {
bt_dev_err(hdev, "no memory for new connection"); bt_dev_err(hdev, "no memory for new connection");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment