Skip to content

Commit

Permalink
Bluetooth: Fix memory leak in hci_connect_le_scan
Browse files Browse the repository at this point in the history
In the implementation of hci_connect_le_scan() when conn is added via
hci_conn_add(), if hci_explicit_conn_params_set() fails the allocated
memory for conn is leaked. Use hci_conn_del() to release it.

Fixes: f75113a ("Bluetooth: add hci_connect_le_scan")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Navid Emamdoost authored and Marcel Holtmann committed Nov 22, 2019
1 parent 7fdf6c6 commit d088337
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,10 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
if (!conn)
return ERR_PTR(-ENOMEM);

if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0)
if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) {
hci_conn_del(conn);
return ERR_PTR(-EBUSY);
}

conn->state = BT_CONNECT;
set_bit(HCI_CONN_SCANNING, &conn->flags);
Expand Down

0 comments on commit d088337

Please sign in to comment.