Bluetooth: Fix potential bt_conn leaks
There's no need to check for BT_CONN_CONNECTED for these HCI events or ACL data. Even if the connection is being disconnected the stack will do the right thing when the disconnect_complete event occurs. Furthermore, these branches were actually leaking the bt_conn if the state wasn't connected after being looked up. Change-Id: I2e22d67cb43a86e742663a896e853de02fe9e325 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
636415212a
commit
7d8e97c9a1
1 changed files with 4 additions and 4 deletions
|
@ -253,7 +253,7 @@ static void hci_acl(struct bt_buf *buf)
|
|||
}
|
||||
|
||||
conn = bt_conn_lookup_handle(buf->acl.handle);
|
||||
if (!conn || conn->state != BT_CONN_CONNECTED) {
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u\n", buf->acl.handle);
|
||||
bt_buf_put(buf);
|
||||
return;
|
||||
|
@ -392,7 +392,7 @@ static void hci_encrypt_change(struct bt_buf *buf)
|
|||
}
|
||||
|
||||
conn = bt_conn_lookup_handle(handle);
|
||||
if (!conn || conn->state != BT_CONN_CONNECTED) {
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to look up conn with handle %u\n", handle);
|
||||
return;
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ static void hci_encrypt_key_refresh_complete(struct bt_buf *buf)
|
|||
}
|
||||
|
||||
conn = bt_conn_lookup_handle(handle);
|
||||
if (!conn || conn->state != BT_CONN_CONNECTED) {
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to look up conn with handle %u\n", handle);
|
||||
return;
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ static void le_ltk_request(struct bt_buf *buf)
|
|||
BT_DBG("handle %u\n", handle);
|
||||
|
||||
conn = bt_conn_lookup_handle(handle);
|
||||
if (!conn || conn->state != BT_CONN_CONNECTED) {
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to lookup conn for handle %u\n", handle);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue