Skip to content

Commit f35dc9c

Browse files
Johan Hedbergnashif
authored andcommitted
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 <[email protected]>
1 parent 2761887 commit f35dc9c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3085,6 +3085,8 @@ static void le_pkey_complete(struct net_buf *buf)
30853085
for (cb = pub_key_cb; cb; cb = cb->_next) {
30863086
cb->func(evt->status ? NULL : evt->key);
30873087
}
3088+
3089+
pub_key_cb = NULL;
30883090
}
30893091

30903092
static void le_dhkey_complete(struct net_buf *buf)
@@ -5878,7 +5880,6 @@ u16_t bt_hci_get_cmd_opcode(struct net_buf *buf)
58785880
#if defined(CONFIG_BT_ECC)
58795881
int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
58805882
{
5881-
struct bt_pub_key_cb *cb;
58825883
int err;
58835884

58845885
/*
@@ -5910,12 +5911,6 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
59105911
return err;
59115912
}
59125913

5913-
for (cb = pub_key_cb; cb; cb = cb->_next) {
5914-
if (cb != new_cb) {
5915-
cb->func(NULL);
5916-
}
5917-
}
5918-
59195914
return 0;
59205915
}
59215916

0 commit comments

Comments
 (0)