diff mbox series

[BlueZ] a2dp: Fix crash when SEP codec has not been initialized

Message ID 20220328203621.1853081-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ] a2dp: Fix crash when SEP codec has not been initialized | expand

Commit Message

Luiz Augusto von Dentz March 28, 2022, 8:36 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If SEP has not been properly discovered avdtp_get_codec may return NULL
thus causing crashes such as when running AVRCP/TG/VLH/BI-01-C after
AVRCP/TG/RCR/BV-04-C
---
 profiles/audio/a2dp.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

bluez.test.bot@gmail.com March 28, 2022, 10:06 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=626995

---Test result---

Test Summary:
CheckPatch                    PASS      1.52 seconds
GitLint                       PASS      0.97 seconds
Prep - Setup ELL              PASS      57.14 seconds
Build - Prep                  PASS      0.91 seconds
Build - Configure             PASS      11.52 seconds
Build - Make                  PASS      1949.57 seconds
Make Check                    PASS      12.99 seconds
Make Check w/Valgrind         PASS      592.63 seconds
Make Distcheck                PASS      313.99 seconds
Build w/ext ELL - Configure   PASS      12.12 seconds
Build w/ext ELL - Make        PASS      1927.87 seconds
Incremental Build with patchesPASS      0.00 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index c3ac432a7..52a21357b 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -2074,6 +2074,11 @@  static struct a2dp_remote_sep *register_remote_sep(void *data, void *user_data)
 	if (sep)
 		return sep;
 
+	if (avdtp_get_codec(rsep)) {
+		error("Unable to get remote sep codec");
+		return NULL;
+	}
+
 	sep = new0(struct a2dp_remote_sep, 1);
 	sep->chan = chan;
 	sep->sep = rsep;
@@ -2206,8 +2211,14 @@  static void load_remote_sep(struct a2dp_channel *chan, GKeyFile *key_file,
 		}
 
 		sep = register_remote_sep(rsep, chan);
-		if (sep)
-			sep->from_cache = true;
+		if (!sep) {
+			avdtp_unregister_remote_sep(chan->session, rsep);
+			/* Update cache */
+			store_remote_seps(chan);
+			continue;
+		}
+
+		sep->from_cache = true;
 	}
 
 	value = g_key_file_get_string(key_file, "Endpoints", "LastUsed", NULL);