Fix crash in smp_br_state_machine_event
p_cb->role value should be checked before it's used
Test: compilation
Bug: 162327732
Change-Id: I5f4ed835621a0a94fa04d41febad02b8f1c11b89
diff --git a/stack/smp/smp_br_main.cc b/stack/smp/smp_br_main.cc
index b06055f..2f5fe76 100644
--- a/stack/smp/smp_br_main.cc
+++ b/stack/smp/smp_br_main.cc
@@ -303,7 +303,6 @@
tSMP_BR_STATE curr_state = p_cb->br_state;
tSMP_BR_SM_TBL state_table;
uint8_t action, entry;
- tSMP_BR_ENTRY_TBL entry_table = smp_br_entry_table[p_cb->role];
SMP_TRACE_EVENT("main %s", __func__);
if (curr_state >= SMP_BR_STATE_MAX) {
@@ -317,6 +316,8 @@
return;
}
+ tSMP_BR_ENTRY_TBL entry_table = smp_br_entry_table[p_cb->role];
+
SMP_TRACE_DEBUG("SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",
(p_cb->role == HCI_ROLE_SLAVE) ? "Slave" : "Master",
smp_get_br_state_name(p_cb->br_state), p_cb->br_state,