Skip to content

Commit e2c982c

Browse files
author
Johan Hedberg
committed
Bluetooth: Fix missing checks for the BT_DEV_READY flag
Several public APIs were not checking the BT_DEV_READY flag, which could lead to hard-to-debug behavior, particularly when the stack lacks an identity address. Add the appropriate checks to these APIs. Signed-off-by: Johan Hedberg <[email protected]>
1 parent 103829a commit e2c982c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,10 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
19191919
{
19201920
struct bt_conn *conn;
19211921

1922+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
1923+
return NULL;
1924+
}
1925+
19221926
if (!bt_le_conn_params_valid(param)) {
19231927
return NULL;
19241928
}

subsys/bluetooth/host/hci_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5265,6 +5265,10 @@ int bt_le_adv_start_internal(const struct bt_le_adv_param *param,
52655265
bool dir_adv = (peer != NULL);
52665266
int err = 0;
52675267

5268+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
5269+
return -EAGAIN;
5270+
}
5271+
52685272
if (!valid_adv_param(param, dir_adv)) {
52695273
return -EINVAL;
52705274
}
@@ -5457,6 +5461,10 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)
54575461
{
54585462
int err;
54595463

5464+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
5465+
return -EAGAIN;
5466+
}
5467+
54605468
/* Check that the parameters have valid values */
54615469
if (!valid_le_scan_param(param)) {
54625470
return -EINVAL;

0 commit comments

Comments
 (0)