Bluetooth: Host: Avoid processing "no change" encryption changes
If the new encryption state is the same as the old one, there's no point in
doing additional processing or callbacks. Simply log a warning and ignore
the HCI event in such a case.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
(cherry picked from commit bf363d7c3e4614ebc9b7e7a051657ae6fde6283b)
diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c
index a9eb0d0..2b79e87 100644
--- a/subsys/bluetooth/host/hci_core.c
+++ b/subsys/bluetooth/host/hci_core.c
@@ -1756,6 +1756,12 @@
return;
}
+ if (conn->encrypt == evt->encrypt) {
+ BT_WARN("No change to encryption state (encrypt 0x%02x)", evt->encrypt);
+ bt_conn_unref(conn);
+ return;
+ }
+
conn->encrypt = evt->encrypt;
#if defined(CONFIG_BT_SMP)