aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-12-05 05:45:22 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-12-05 06:13:00 -0500
commit22078800c337cf374d58b63a5b1f670d470e6dbf (patch)
tree8dbcd74c8e7bdd094e44a39634e3d2891dd7954d /net
parent0256325ed666af8346c89deb9d437c2209f463cb (diff)
Bluetooth: Fix memory leaks from discovery filter UUID list
In case of failure or when unplugging a controller, the allocated memory for the UUID list of the discovery filter is not freed. Use the newly introduced helper for reset the discovery filter and with that also freeing existing memory. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_core.c1
-rw-r--r--net/bluetooth/mgmt.c12
2 files changed, 11 insertions, 2 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3c81b5cdda83..8b3f839ba826 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -4255,6 +4255,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
4255 hci_remote_oob_data_clear(hdev); 4255 hci_remote_oob_data_clear(hdev);
4256 hci_bdaddr_list_clear(&hdev->le_white_list); 4256 hci_bdaddr_list_clear(&hdev->le_white_list);
4257 hci_conn_params_clear_all(hdev); 4257 hci_conn_params_clear_all(hdev);
4258 hci_discovery_filter_clear(hdev);
4258 hci_dev_unlock(hdev); 4259 hci_dev_unlock(hdev);
4259 4260
4260 hci_dev_put(hdev); 4261 hci_dev_put(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 104c4cc921da..74571a4b85ec 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3870,9 +3870,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3870 goto failed; 3870 goto failed;
3871 } 3871 }
3872 3872
3873 /* Clear the discovery filter first to free any previously
3874 * allocated memory for the UUID list.
3875 */
3876 hci_discovery_filter_clear(hdev);
3877
3873 hdev->discovery.type = cp->type; 3878 hdev->discovery.type = cp->type;
3874 hdev->discovery.rssi = HCI_RSSI_INVALID;
3875 hdev->discovery.uuid_count = 0;
3876 3879
3877 hci_req_init(&req, hdev); 3880 hci_req_init(&req, hdev);
3878 3881
@@ -3957,6 +3960,11 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
3957 goto failed; 3960 goto failed;
3958 } 3961 }
3959 3962
3963 /* Clear the discovery filter first to free any previously
3964 * allocated memory for the UUID list.
3965 */
3966 hci_discovery_filter_clear(hdev);
3967
3960 hdev->discovery.type = cp->type; 3968 hdev->discovery.type = cp->type;
3961 hdev->discovery.rssi = cp->rssi; 3969 hdev->discovery.rssi = cp->rssi;
3962 hdev->discovery.uuid_count = uuid_count; 3970 hdev->discovery.uuid_count = uuid_count;