Skip to content

Commit 326786e

Browse files
PavelVPVcarlescufi
authored andcommitted
Bluetooth: Mesh: Avoid indefinite timeout when duration less than zero
`struct bt_le_ext_adv_start_param.timeout` resolution is in 10ms. When duration is less than 10ms, division will be evaluated to zero, which will result in indefinite timeout. Set timeout to 10ms to avoid indefinite timeout. The advertisement will end earlier anyway after the event is finished. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 55c4e06 commit 326786e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/bluetooth/mesh/adv_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ int bt_mesh_adv_gatt_start(const struct bt_le_adv_param *param,
417417
struct bt_mesh_ext_adv *adv = gatt_adv_get();
418418
struct bt_le_ext_adv_start_param start = {
419419
/* Timeout is set in 10 ms steps, with 0 indicating "forever" */
420-
.timeout = (duration == SYS_FOREVER_MS) ? 0 : (duration / 10),
420+
.timeout = (duration == SYS_FOREVER_MS) ? 0 : MAX(1, duration / 10),
421421
};
422422

423423
BT_DBG("Start advertising %d ms", duration);

0 commit comments

Comments
 (0)