Bluetooth: SMP: Stop new pairing early if MAX_PAIR has been reached
Stop the pairing procedure in the request phase if no storage is available for the keys. This avoids the pairing procedure from failing during the key distribution phase. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
3263f93747
commit
f1c7371494
2 changed files with 22 additions and 1 deletions
|
@ -303,7 +303,7 @@ typedef enum __packed {
|
||||||
*
|
*
|
||||||
* This function may return error if required level of security is not possible
|
* This function may return error if required level of security is not possible
|
||||||
* to achieve due to local or remote device limitation (e.g., input output
|
* to achieve due to local or remote device limitation (e.g., input output
|
||||||
* capabilities).
|
* capabilities), or if the maximum number of paired devices has been reached.
|
||||||
*
|
*
|
||||||
* @param conn Connection object.
|
* @param conn Connection object.
|
||||||
* @param sec Requested security level.
|
* @param sec Requested security level.
|
||||||
|
|
|
@ -2422,6 +2422,13 @@ int bt_smp_send_security_req(struct bt_conn *conn)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
conn->le.keys = bt_keys_get_addr(conn->id, &conn->le.dst);
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (smp_init(smp) != 0) {
|
if (smp_init(smp) != 0) {
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
@ -2457,6 +2464,13 @@ static u8_t smp_pairing_req(struct bt_smp *smp, struct net_buf *buf)
|
||||||
return BT_SMP_ERR_ENC_KEY_SIZE;
|
return BT_SMP_ERR_ENC_KEY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
conn->le.keys = bt_keys_get_addr(conn->id, &conn->le.dst);
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
return BT_SMP_ERR_UNSPECIFIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If we already sent a security request then the SMP context
|
/* If we already sent a security request then the SMP context
|
||||||
* is already initialized.
|
* is already initialized.
|
||||||
*/
|
*/
|
||||||
|
@ -2601,6 +2615,13 @@ int bt_smp_send_pairing_req(struct bt_conn *conn)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
conn->le.keys = bt_keys_get_addr(conn->id, &conn->le.dst);
|
||||||
|
if (!conn->le.keys) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (smp_init(smp)) {
|
if (smp_init(smp)) {
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue