Bluetooth: Fix changing advertising setting while LE is connected
Subsystems (2)
PATCH 1/1 Bluetooth: Fix changing advertising setting while LE is connected
From: Johan Hedberg <[email protected]>
We only (re)enable advertising when LE is disconnected. Trying to enable advertising using mgmt_set_advertising while connected should simply change the flag but not do anything else (until the connection gets dropped). This patch fixes this by making an LE connection lookup to determine whether there are any connected devices or not.
--- net/bluetooth/mgmt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/bluetooth/mgmt.c +7 -1
@@ -3264,7 +3264,13 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, u1 val = !!cp->val; enabled =test_bit (HCI_ADVERTISING , &hdev->dev_flags); -if (!hdev_is_powered (hdev) || val == enabled) { +/* The following conditions are ones which mean that we should +* not do any HCI communication but directly send a mgmt +* response to user space (after toggling the flag if +* necessary). +*/ +if (!hdev_is_powered (hdev) || val == enabled || +hci_conn_hash_lookup_state (hdev,LE_LINK ,BT_CONNECTED )) {bool changed = false;if (val !=test_bit (HCI_ADVERTISING , &hdev->dev_flags)) {
Signature · 1 line
1.8.3.1
Marcel Holtmann
maintainerHi Johan,
Quoted 10 lines
We only (re)enable advertising when LE is disconnected. Trying to enable advertising using
mgmt_set_advertisingwhile connected should simply change the flag but not do anything else (until the connection gets dropped). This patch fixes this by making an LE connection lookup to determine whether there are any connected devices or not.Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/mgmt.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel