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:
Johan Hedberg 2019-03-22 12:48:32 +02:00 committed by Johan Hedberg
commit f811e5446a
2 changed files with 12 additions and 0 deletions

View file

@ -1919,6 +1919,10 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
{
struct bt_conn *conn;
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
return NULL;
}
if (!bt_le_conn_params_valid(param)) {
return NULL;
}

View file

@ -5265,6 +5265,10 @@ int bt_le_adv_start_internal(const struct bt_le_adv_param *param,
bool dir_adv = (peer != NULL);
int err = 0;
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
return -EAGAIN;
}
if (!valid_adv_param(param, dir_adv)) {
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;
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
return -EAGAIN;
}
/* Check that the parameters have valid values */
if (!valid_le_scan_param(param)) {
return -EINVAL;