Bluetooth: Fix memory leak in hci_connect_le_scan
[sfrench/cifs-2.6.git] / net / bluetooth / hci_conn.c
index 7ff92dd4c53cd4c783986776ae89308b439ebc3f..87691404d0c6b65f8999df08f26abcb8a6c0494c 100644 (file)
@@ -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);