From ad839868b5aed781ba54af620e439e5c96ee019a Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Mon, 24 Jun 2013 13:19:13 -0700 Subject: [PATCH] LE: Fix crash on LE mouse reconnect Sometimes, a GKI exception may be observed when re-connecting to an LE mouse. This patch properly handles the encryption state change, avoiding a possible race condition leading to the exception. Change-Id: I4cf139c1ac22e71b598272fccebf645cd73fdf6a --- stack/btu/btu_hcif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c index a486036..69b3882 100644 --- a/stack/btu/btu_hcif.c +++ b/stack/btu/btu_hcif.c @@ -2241,12 +2241,15 @@ static void btu_hcif_enhanced_flush_complete_evt (UINT8 *p, UINT16 evt_len) static void btu_hcif_encyption_key_refresh_cmpl_evt (UINT8 *p, UINT16 evt_len) { UINT8 status; + UINT8 enc_enable = 0; UINT16 handle; STREAM_TO_UINT8 (status, p); STREAM_TO_UINT16 (handle, p); - btm_sec_encrypt_change (handle, status, 1); + if (status == HCI_SUCCESS) enc_enable = 1; + + btm_sec_encrypt_change (handle, status, enc_enable); } static void btu_ble_process_adv_pkt (UINT8 *p, UINT16 evt_len) -- 2.11.0