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 <johan.hedberg@intel.com>
This commit is contained in:
parent
12a413779d
commit
f811e5446a
2 changed files with 12 additions and 0 deletions
|
@ -1919,6 +1919,10 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
||||||
{
|
{
|
||||||
struct bt_conn *conn;
|
struct bt_conn *conn;
|
||||||
|
|
||||||
|
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!bt_le_conn_params_valid(param)) {
|
if (!bt_le_conn_params_valid(param)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5265,6 +5265,10 @@ int bt_le_adv_start_internal(const struct bt_le_adv_param *param,
|
||||||
bool dir_adv = (peer != NULL);
|
bool dir_adv = (peer != NULL);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (!valid_adv_param(param, dir_adv)) {
|
if (!valid_adv_param(param, dir_adv)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -5457,6 +5461,10 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check that the parameters have valid values */
|
/* Check that the parameters have valid values */
|
||||||
if (!valid_le_scan_param(param)) {
|
if (!valid_le_scan_param(param)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue