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 github-actions[bot] committed Jun 11, 2024
1 parent 6477a75 commit 13519a6
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) {
LOG_WRN("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 13519a6

Please sign in to comment.