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 <[email protected]>
(cherry picked from commit bf363d7)
  • Loading branch information
jhedberg authored and henrikbrixandersen committed Jun 25, 2024
1 parent 8cd7337 commit fee8920
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 @@ -2062,6 +2062,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 fee8920

Please sign in to comment.