diff mbox series

Bluetooth: Fix handling of HCI_LE_Advertising_Set_Terminated event

Message ID 20210623035902.3572144-1-luiz.dentz@gmail.com
State New
Headers show
Series Bluetooth: Fix handling of HCI_LE_Advertising_Set_Terminated event | expand

Commit Message

Luiz Augusto von Dentz June 23, 2021, 3:59 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Error status of this event means that it has ended due reasons other
than a connection:

 'If advertising has terminated as a result of the advertising duration
 elapsing, the Status parameter shall be set to the error code
 Advertising Timeout (0x3C).'

 'If advertising has terminated because the
 Max_Extended_Advertising_Events was reached, the Status parameter
 shall be set to the error code Limit Reached (0x43).'

Fixes: acf0aeae431a0 ("Bluetooth: Handle ADv set terminated event")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_event.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Marcel Holtmann June 25, 2021, 9:44 p.m. UTC | #1
Hi Luiz,

> Error status of this event means that it has ended due reasons other

> than a connection:

> 

> 'If advertising has terminated as a result of the advertising duration

> elapsing, the Status parameter shall be set to the error code

> Advertising Timeout (0x3C).'

> 

> 'If advertising has terminated because the

> Max_Extended_Advertising_Events was reached, the Status parameter

> shall be set to the error code Limit Reached (0x43).'

> 

> Fixes: acf0aeae431a0 ("Bluetooth: Handle ADv set terminated event")

> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

> ---

> net/bluetooth/hci_event.c | 13 ++++++++++++-

> 1 file changed, 12 insertions(+), 1 deletion(-)


patch has been applied to bluetooth-next tree.

Regards

Marcel
diff mbox series

Patch

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1a4279dfb93e..9c18129e4dbc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -5319,8 +5319,19 @@  static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 	BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
 
-	if (ev->status)
+	if (ev->status) {
+		struct adv_info *adv;
+
+		adv = hci_find_adv_instance(hdev, ev->handle);
+		if (!adv)
+			return;
+
+		/* Remove advertising as it has been terminated */
+		hci_remove_adv_instance(hdev, ev->handle);
+		mgmt_advertising_removed(NULL, hdev, ev->handle);
+
 		return;
+	}
 
 	conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle));
 	if (conn) {