From 84bf3113bc56121e85e0e8c58b58308211826006 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Mon, 2 Jun 2025 14:10:18 +0200 Subject: [PATCH] Bluetooth: BAP: SD: Fix missing clear of notify flag on reject For add and modify source, if the request was rejected by the application layer, the BASS_RECV_STATE_INTERNAL_FLAG_NOTIFY_PEND would be set but not unset. Add unsetting the flag on reject. Signed-off-by: Emil Gydesen --- subsys/bluetooth/audio/bap_scan_delegator.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subsys/bluetooth/audio/bap_scan_delegator.c b/subsys/bluetooth/audio/bap_scan_delegator.c index 002a50b76297e..1f0964fa96fd7 100644 --- a/subsys/bluetooth/audio/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/bap_scan_delegator.c @@ -679,6 +679,9 @@ static int scan_delegator_add_source(struct bt_conn *conn, LOG_DBG("PA sync %u from %p was rejected with reason %d", pa_sync, conn, err); + atomic_clear_bit(internal_state->flags, + BASS_RECV_STATE_INTERNAL_FLAG_NOTIFY_PEND); + return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } } @@ -875,6 +878,9 @@ static int scan_delegator_mod_src(struct bt_conn *conn, LOG_DBG("PA sync %u from %p was rejected with reason %d", pa_sync, conn, err); + atomic_clear_bit(internal_state->flags, + BASS_RECV_STATE_INTERNAL_FLAG_NOTIFY_PEND); + return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); } } else if (pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC && @@ -886,6 +892,9 @@ static int scan_delegator_mod_src(struct bt_conn *conn, if (err != 0) { LOG_DBG("PA sync term from %p was rejected with reason %d", conn, err); + atomic_clear_bit(internal_state->flags, + BASS_RECV_STATE_INTERNAL_FLAG_NOTIFY_PEND); + return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); }