Commit 0256325e authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Add helper function for clearing the discovery filter

The discovery filter allocates memory for its UUID list. So use
a helper function to free it and reset it to default states.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 66ea9427
...@@ -509,6 +509,14 @@ static inline void discovery_init(struct hci_dev *hdev) ...@@ -509,6 +509,14 @@ static inline void discovery_init(struct hci_dev *hdev)
hdev->discovery.rssi = HCI_RSSI_INVALID; hdev->discovery.rssi = HCI_RSSI_INVALID;
} }
static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
{
hdev->discovery.rssi = HCI_RSSI_INVALID;
hdev->discovery.uuid_count = 0;
kfree(hdev->discovery.uuids);
hdev->discovery.uuids = NULL;
}
bool hci_discovery_active(struct hci_dev *hdev); bool hci_discovery_active(struct hci_dev *hdev);
void hci_discovery_set_state(struct hci_dev *hdev, int state); void hci_discovery_set_state(struct hci_dev *hdev, int state);
......
...@@ -2061,10 +2061,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) ...@@ -2061,10 +2061,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
* count, it is important to actually free the allocated * count, it is important to actually free the allocated
* list of UUIDs here. * list of UUIDs here.
*/ */
hdev->discovery.rssi = HCI_RSSI_INVALID; hci_discovery_filter_clear(hdev);
hdev->discovery.uuid_count = 0;
kfree(hdev->discovery.uuids);
hdev->discovery.uuids = NULL;
if (old_state != DISCOVERY_STARTING) if (old_state != DISCOVERY_STARTING)
mgmt_discovering(hdev, 0); mgmt_discovering(hdev, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment