Bluetooth: Fix public key callback management
Clear the callback list once generation is complete and we've done calling all callbacks. This lets us use bt_pub_key_gen() multiple times, which before this patch could have resulted in a corrupt linked list. Also remove redundant callback dispatching from bt_pub_key_gen() since the function checks for the PUB_KEY_BUSY flag in the beginning, i.e. there cannot be other pending generation actions at this point in the code. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
60f47c2d7e
commit
d6c34c4644
1 changed files with 2 additions and 7 deletions
|
@ -3065,6 +3065,8 @@ static void le_pkey_complete(struct net_buf *buf)
|
|||
for (cb = pub_key_cb; cb; cb = cb->_next) {
|
||||
cb->func(evt->status ? NULL : evt->key);
|
||||
}
|
||||
|
||||
pub_key_cb = NULL;
|
||||
}
|
||||
|
||||
static void le_dhkey_complete(struct net_buf *buf)
|
||||
|
@ -5850,7 +5852,6 @@ int bt_br_set_discoverable(bool enable)
|
|||
#if defined(CONFIG_BT_ECC)
|
||||
int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
|
||||
{
|
||||
struct bt_pub_key_cb *cb;
|
||||
int err;
|
||||
|
||||
/*
|
||||
|
@ -5882,12 +5883,6 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
|
|||
return err;
|
||||
}
|
||||
|
||||
for (cb = pub_key_cb; cb; cb = cb->_next) {
|
||||
if (cb != new_cb) {
|
||||
cb->func(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue