Skip to content
Permalink
Browse files

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>
  • Loading branch information...
jhedberg committed Jun 25, 2019
1 parent 60f47c2 commit d6c34c4644c8fa771ed138b166be4500867c9332
Showing with 2 additions and 7 deletions.
  1. +2 −7 subsys/bluetooth/host/hci_core.c
@@ -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;
}

0 comments on commit d6c34c4

Please sign in to comment.
You can’t perform that action at this time.