From bc710a49f150d6cc39f5aeb87f2e4b4a6ac48bf3 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Thu, 6 Jul 2023 11:25:05 +0200 Subject: [PATCH] Bluetooth: audio: unicast_server: Do not store metadata if rejected This moves copying of parameters after application return value validation so that the metadata is not stored if rejected. Signed-off-by: Mariusz Skamra --- subsys/bluetooth/audio/bap_unicast_server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/audio/bap_unicast_server.c b/subsys/bluetooth/audio/bap_unicast_server.c index 54c37649d44..d056128a250 100644 --- a/subsys/bluetooth/audio/bap_unicast_server.c +++ b/subsys/bluetooth/audio/bap_unicast_server.c @@ -129,16 +129,16 @@ int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_audio err = -ENOTSUP; } - ep = stream->ep; - for (size_t i = 0U; i < meta_count; i++) { - (void)memcpy(&ep->codec_cfg.meta[i], &meta[i], sizeof(ep->codec_cfg.meta[i])); - } - if (err) { LOG_ERR("Metadata failed: err %d, code %u, reason %u", err, rsp.code, rsp.reason); return err; } + ep = stream->ep; + for (size_t i = 0U; i < meta_count; i++) { + (void)memcpy(&ep->codec_cfg.meta[i], &meta[i], sizeof(ep->codec_cfg.meta[i])); + } + /* Set the state to the same state to trigger the notifications */ ascs_ep_set_state(ep, ep->status.state);