From 326786efd62d19ec24909b806928e496c90a45f0 Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Wed, 21 Sep 2022 09:37:08 +0200 Subject: [PATCH] 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 --- subsys/bluetooth/mesh/adv_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index dc761c58979..242dee6027c 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -417,7 +417,7 @@ int bt_mesh_adv_gatt_start(const struct bt_le_adv_param *param, struct bt_mesh_ext_adv *adv = gatt_adv_get(); struct bt_le_ext_adv_start_param start = { /* Timeout is set in 10 ms steps, with 0 indicating "forever" */ - .timeout = (duration == SYS_FOREVER_MS) ? 0 : (duration / 10), + .timeout = (duration == SYS_FOREVER_MS) ? 0 : MAX(1, duration / 10), }; BT_DBG("Start advertising %d ms", duration);