Skip to content

Commit 00d8068

Browse files
joerchannashif
authored andcommitted
Bluetooth: host: Fix wrong error code type passed to security changed
Fix wrong error code type passed to security changed, passed SMP error code instead of HCI error code. Signed-off-by: Joakim Andersson <[email protected]>
1 parent bdf1452 commit 00d8068

File tree

1 file changed

+23
-1
lines changed
  • subsys/bluetooth/host

1 file changed

+23
-1
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,26 @@ static void smp_reset(struct bt_smp *smp)
18071807
}
18081808
}
18091809

1810+
static uint8_t hci_err_get(enum bt_security_err err)
1811+
{
1812+
switch (err) {
1813+
case BT_SECURITY_ERR_SUCCESS:
1814+
return BT_HCI_ERR_SUCCESS;
1815+
case BT_SECURITY_ERR_AUTH_FAIL:
1816+
return BT_HCI_ERR_AUTH_FAIL;
1817+
case BT_SECURITY_ERR_PIN_OR_KEY_MISSING:
1818+
return BT_HCI_ERR_PIN_OR_KEY_MISSING;
1819+
case BT_SECURITY_ERR_PAIR_NOT_SUPPORTED:
1820+
return BT_HCI_ERR_PAIRING_NOT_SUPPORTED;
1821+
case BT_SECURITY_ERR_PAIR_NOT_ALLOWED:
1822+
return BT_HCI_ERR_PAIRING_NOT_ALLOWED;
1823+
case BT_SECURITY_ERR_INVALID_PARAM:
1824+
return BT_HCI_ERR_INVALID_PARAM;
1825+
default:
1826+
return BT_HCI_ERR_UNSPECIFIED;
1827+
}
1828+
}
1829+
18101830
/* Note: This function not only does set the status but also calls smp_reset
18111831
* at the end which clears any flags previously set.
18121832
*/
@@ -1852,7 +1872,9 @@ static void smp_pairing_complete(struct bt_smp *smp, uint8_t status)
18521872
}
18531873

18541874
if (!atomic_test_bit(smp->flags, SMP_FLAG_KEYS_DISTR)) {
1855-
bt_conn_security_changed(conn, status, security_err);
1875+
bt_conn_security_changed(conn,
1876+
hci_err_get(security_err),
1877+
security_err);
18561878
}
18571879

18581880
if (bt_auth && bt_auth->pairing_failed) {

0 commit comments

Comments
 (0)