bluetooth: mesh: avoid improper access to internal structures
Nothing in the API description the delayed work structure sanctions direct reference to internal fields. Do not assume that a delayed work item can be submitted without delay by invoking k_work_submit() with a reference to the contained work item. Instead submit with the delayed API and no wait. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
550a1f411d
commit
cd2a5dd612
2 changed files with 6 additions and 6 deletions
|
@ -438,7 +438,7 @@ void bt_mesh_beacon_ivu_initiator(bool enable)
|
||||||
atomic_set_bit_to(bt_mesh.flags, BT_MESH_IVU_INITIATOR, enable);
|
atomic_set_bit_to(bt_mesh.flags, BT_MESH_IVU_INITIATOR, enable);
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
k_work_submit(&beacon_timer.work);
|
k_delayed_work_submit(&beacon_timer, K_NO_WAIT);
|
||||||
} else if (!bt_mesh_beacon_enabled()) {
|
} else if (!bt_mesh_beacon_enabled()) {
|
||||||
k_delayed_work_cancel(&beacon_timer);
|
k_delayed_work_cancel(&beacon_timer);
|
||||||
}
|
}
|
||||||
|
@ -455,13 +455,13 @@ static void subnet_beacon_enable(struct bt_mesh_subnet *sub)
|
||||||
void bt_mesh_beacon_enable(void)
|
void bt_mesh_beacon_enable(void)
|
||||||
{
|
{
|
||||||
if (!bt_mesh_is_provisioned()) {
|
if (!bt_mesh_is_provisioned()) {
|
||||||
k_work_submit(&beacon_timer.work);
|
k_delayed_work_submit(&beacon_timer, K_NO_WAIT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_mesh_subnet_foreach(subnet_beacon_enable);
|
bt_mesh_subnet_foreach(subnet_beacon_enable);
|
||||||
|
|
||||||
k_work_submit(&beacon_timer.work);
|
k_delayed_work_submit(&beacon_timer, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_mesh_beacon_disable(void)
|
void bt_mesh_beacon_disable(void)
|
||||||
|
|
|
@ -239,7 +239,7 @@ uint8_t bt_mesh_hb_pub_set(struct bt_mesh_hb_pub *new_pub)
|
||||||
* periodic publishing.
|
* periodic publishing.
|
||||||
*/
|
*/
|
||||||
if (pub.period && pub.count) {
|
if (pub.period && pub.count) {
|
||||||
k_work_submit(&pub_timer.work);
|
k_delayed_work_submit(&pub_timer, K_NO_WAIT);
|
||||||
} else {
|
} else {
|
||||||
k_delayed_work_cancel(&pub_timer);
|
k_delayed_work_cancel(&pub_timer);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ void bt_mesh_hb_start(void)
|
||||||
{
|
{
|
||||||
if (pub.count && pub.period) {
|
if (pub.count && pub.period) {
|
||||||
BT_DBG("Starting heartbeat publication");
|
BT_DBG("Starting heartbeat publication");
|
||||||
k_work_submit(&pub_timer.work);
|
k_delayed_work_submit(&pub_timer, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +351,6 @@ void bt_mesh_hb_resume(void)
|
||||||
{
|
{
|
||||||
if (pub.period && pub.count) {
|
if (pub.period && pub.count) {
|
||||||
BT_DBG("Starting heartbeat publication");
|
BT_DBG("Starting heartbeat publication");
|
||||||
k_work_submit(&pub_timer.work);
|
k_delayed_work_submit(&pub_timer, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue