Skip to content

Commit

Permalink
Bluetooth: Host: Avoid processing "no change" encryption changes
Browse files Browse the repository at this point in the history
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 bf363d7)
  • Loading branch information
jhedberg authored and cfriedt committed Jan 21, 2025
1 parent 62ad640 commit baed41e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,12 @@ static void hci_encrypt_change(struct net_buf *buf)
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)
Expand Down

0 comments on commit baed41e

Please sign in to comment.