Bluetooth: Mesh: Fix unref null pointer

When pb-gatt advertising enabled, after extablish connect,
will call `cb->connected` and `cb->adv_send`.

In previous connected also clear `ADV_FLAG_PROXY` flag, but
in `adv_send` will attempt unref null point buffers.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
Lingao Meng 2022-03-22 14:15:27 +08:00 committed by Carles Cufí
commit 58a501d6cd

View file

@ -343,9 +343,11 @@ static void adv_sent(struct bt_le_ext_adv *instance,
BT_DBG("Advertising stopped after %u ms", (uint32_t)duration);
atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE);
atomic_clear_bit(adv->flags, ADV_FLAG_PROXY);
if (!atomic_test_and_clear_bit(adv->flags, ADV_FLAG_PROXY)) {
if (adv->buf) {
net_buf_unref(adv->buf);
adv->buf = NULL;
}
(void)schedule_send(adv);