aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2016-08-28 13:53:34 -0400
committerMarcel Holtmann <marcel@holtmann.org>2016-09-19 14:19:34 -0400
commit37d3a1fab50fa07ac706787646e61c60e7c520e0 (patch)
tree8c0c1576333831c7fed1195078d6f447968a636c
parent38ceaa00d02dceb22c6bdd5268f5a44d5c00e123 (diff)
Bluetooth: mgmt: Fix sending redundant event for Advertising Instance
When an Advertising Instance is removed, the Advertising Removed event shouldn't be sent to the same socket that issued the Remove Advertising command (it gets a command complete event instead). The mgmt_advertising_removed() function already has a parameter for skipping a specific socket, but there was no code to propagate the right value to this parameter. This patch fixes the issue by making sure the intermediate hci_req_clear_adv_instance() function gets the socket pointer. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_request.c11
-rw-r--r--net/bluetooth/hci_request.h5
-rw-r--r--net/bluetooth/mgmt.c6
3 files changed, 12 insertions, 10 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index b0e23dfc5c34..9968b1c7c03a 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1194,7 +1194,7 @@ static void adv_timeout_expire(struct work_struct *work)
1194 1194
1195 hci_req_init(&req, hdev); 1195 hci_req_init(&req, hdev);
1196 1196
1197 hci_req_clear_adv_instance(hdev, &req, instance, false); 1197 hci_req_clear_adv_instance(hdev, NULL, &req, instance, false);
1198 1198
1199 if (list_empty(&hdev->adv_instances)) 1199 if (list_empty(&hdev->adv_instances))
1200 __hci_req_disable_advertising(&req); 1200 __hci_req_disable_advertising(&req);
@@ -1284,8 +1284,9 @@ static void cancel_adv_timeout(struct hci_dev *hdev)
1284 * setting. 1284 * setting.
1285 * - force == false: Only instances that have a timeout will be removed. 1285 * - force == false: Only instances that have a timeout will be removed.
1286 */ 1286 */
1287void hci_req_clear_adv_instance(struct hci_dev *hdev, struct hci_request *req, 1287void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
1288 u8 instance, bool force) 1288 struct hci_request *req, u8 instance,
1289 bool force)
1289{ 1290{
1290 struct adv_info *adv_instance, *n, *next_instance = NULL; 1291 struct adv_info *adv_instance, *n, *next_instance = NULL;
1291 int err; 1292 int err;
@@ -1311,7 +1312,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct hci_request *req,
1311 rem_inst = adv_instance->instance; 1312 rem_inst = adv_instance->instance;
1312 err = hci_remove_adv_instance(hdev, rem_inst); 1313 err = hci_remove_adv_instance(hdev, rem_inst);
1313 if (!err) 1314 if (!err)
1314 mgmt_advertising_removed(NULL, hdev, rem_inst); 1315 mgmt_advertising_removed(sk, hdev, rem_inst);
1315 } 1316 }
1316 } else { 1317 } else {
1317 adv_instance = hci_find_adv_instance(hdev, instance); 1318 adv_instance = hci_find_adv_instance(hdev, instance);
@@ -1325,7 +1326,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct hci_request *req,
1325 1326
1326 err = hci_remove_adv_instance(hdev, instance); 1327 err = hci_remove_adv_instance(hdev, instance);
1327 if (!err) 1328 if (!err)
1328 mgmt_advertising_removed(NULL, hdev, instance); 1329 mgmt_advertising_removed(sk, hdev, instance);
1329 } 1330 }
1330 } 1331 }
1331 1332
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
index b2d044bdc732..ac1e11006f38 100644
--- a/net/bluetooth/hci_request.h
+++ b/net/bluetooth/hci_request.h
@@ -73,8 +73,9 @@ void __hci_req_update_scan_rsp_data(struct hci_request *req, u8 instance);
73 73
74int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance, 74int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance,
75 bool force); 75 bool force);
76void hci_req_clear_adv_instance(struct hci_dev *hdev, struct hci_request *req, 76void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
77 u8 instance, bool force); 77 struct hci_request *req, u8 instance,
78 bool force);
78 79
79void __hci_req_update_class(struct hci_request *req); 80void __hci_req_update_class(struct hci_request *req);
80 81
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9071886df194..f9af5f7c2ea2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -929,7 +929,7 @@ static int clean_up_hci_state(struct hci_dev *hdev)
929 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 929 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
930 } 930 }
931 931
932 hci_req_clear_adv_instance(hdev, NULL, 0x00, false); 932 hci_req_clear_adv_instance(hdev, NULL, NULL, 0x00, false);
933 933
934 if (hci_dev_test_flag(hdev, HCI_LE_ADV)) 934 if (hci_dev_test_flag(hdev, HCI_LE_ADV))
935 __hci_req_disable_advertising(&req); 935 __hci_req_disable_advertising(&req);
@@ -1697,7 +1697,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1697 enabled = lmp_host_le_capable(hdev); 1697 enabled = lmp_host_le_capable(hdev);
1698 1698
1699 if (!val) 1699 if (!val)
1700 hci_req_clear_adv_instance(hdev, NULL, 0x00, true); 1700 hci_req_clear_adv_instance(hdev, NULL, NULL, 0x00, true);
1701 1701
1702 if (!hdev_is_powered(hdev) || val == enabled) { 1702 if (!hdev_is_powered(hdev) || val == enabled) {
1703 bool changed = false; 1703 bool changed = false;
@@ -6182,7 +6182,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
6182 6182
6183 hci_req_init(&req, hdev); 6183 hci_req_init(&req, hdev);
6184 6184
6185 hci_req_clear_adv_instance(hdev, &req, cp->instance, true); 6185 hci_req_clear_adv_instance(hdev, sk, &req, cp->instance, true);
6186 6186
6187 if (list_empty(&hdev->adv_instances)) 6187 if (list_empty(&hdev->adv_instances))
6188 __hci_req_disable_advertising(&req); 6188 __hci_req_disable_advertising(&req);