From 529cab4137c6f6588e50e8afdb14c847cd158bf9 Mon Sep 17 00:00:00 2001 From: Lyle Zhu Date: Wed, 3 Jul 2024 17:19:27 +0800 Subject: [PATCH] Bluetooth: A2DP: Check the pointer before using Check the pointer `sep` before using it. Fixes #74734. (cherry picked from commit c9708ff951e5915a9b68d23e6ec960fc265bb2a6) Original-Signed-off-by: Lyle Zhu GitOrigin-RevId: c9708ff951e5915a9b68d23e6ec960fc265bb2a6 Change-Id: Iccfdc1076259d05077c96921eaf590238392cc38 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5680119 Commit-Queue: Fabio Baltieri Reviewed-by: Fabio Baltieri Tested-by: ChromeOS Prod (Robot) --- subsys/bluetooth/host/classic/a2dp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/host/classic/a2dp.c b/subsys/bluetooth/host/classic/a2dp.c index 9377675f7e2..76300861c1b 100644 --- a/subsys/bluetooth/host/classic/a2dp.c +++ b/subsys/bluetooth/host/classic/a2dp.c @@ -195,11 +195,10 @@ static int a2dp_set_config_ind(struct bt_avdtp *session, struct bt_avdtp_sep *se int err; *errcode = 0; + + __ASSERT(sep, "Invalid sep"); + ep = CONTAINER_OF(sep, struct bt_a2dp_ep, sep); - if (ep == NULL) { - *errcode = BT_AVDTP_BAD_ACP_SEID; - return -1; - } /* parse the configuration */ codec_info_element_len = 4U;