]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Bluetooth: Fix memory leak in hci_connect_le_scan
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Thu, 21 Nov 2019 20:20:36 +0000 (14:20 -0600)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 06:00:53 +0000 (01:00 -0500)
BugLink: https://bugs.launchpad.net/bugs/1861710
commit d088337c38a5cd8f0230fbf2d514ff7672f9d0d3 upstream.

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: f75113a26008 ("Bluetooth: add hci_connect_le_scan")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
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);