Skip to contentSkip to conversation

a2dp: Fix crash when SEP codec has not been initialized

PATCH In review Luiz Augusto von Dentz 2 participants 4 messages Nov 23, 2020 – Nov 24, 2020 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 a2dp: Fix crash when SEP codec has not been initialized

From: Luiz Augusto von Dentz <[email protected]>

If SEP has not been properly discovered avdtp_get_codec may return NULL thus causing crashes such as:

https://github.com/bluez/bluez/issues/57

---
 profiles/audio/a2dp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
profiles/audio/a2dp.c +8 -3
index 59d11a0aa..f1e4fa990 100644
@@ -1887,8 +1887,8 @@ static void register_remote_sep(void *data, void *user_data)
 				sep, remote_sep_free) == FALSE) {
 		error("Could not register remote sep %s", sep->path);
 		free(sep->path);
-		sep->path = NULL;
-		goto done;
+		free(sep);
+		return;
 	}
 
 	DBG("Found remote SEP: %s", sep->path);
@@ -2627,10 +2627,15 @@ static void store_remote_sep(void *data, void *user_data)
 	GKeyFile *key_file = user_data;
 	char seid[4], value[256];
 	struct avdtp_service_capability *service = avdtp_get_codec(sep->sep);
-	struct avdtp_media_codec_capability *codec = (void *) service->data;
+	struct avdtp_media_codec_capability *codec;
 	unsigned int i;
 	ssize_t offset;
 
+	if (!service)
+		return;
+
+	codec = (void *) service->data;
+
 	sprintf(seid, "%02hhx", avdtp_get_seid(sep->sep));
 
 	offset = sprintf(value, "%02hhx:%02hhx:%02hhx:",
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

PATCH 2/2 avdtp: Fix not sending GetCapabilities

From: Luiz Augusto von Dentz <[email protected]>

It remote SEP has no codec capabilities it must be read with GetCapabilities/GetAllCapabilities otherwise we cannot match it with a local SEP.

---
 profiles/audio/avdtp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
profiles/audio/avdtp.c +2 -1
index ff0a124c3..1093a3543 100644
@@ -2706,7 +2706,8 @@ static gboolean avdtp_discover_resp(struct avdtp *session,
 
 		sep = find_remote_sep(session->seps, resp->seps[i].seid);
 		if (sep && sep->type == resp->seps[i].type &&
-				sep->media_type == resp->seps[i].media_type)
+				sep->media_type == resp->seps[i].media_type &&
+				sep->codec)
 			continue;
 
 		if (resp->seps[i].inuse && !stream)
Signature · 1 line
2.26.2
#2 lore raw
In reply to Luiz Augusto von Dentz

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=389671

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

author maintainer
#3 lore raw

Hi,

Quoted 20 lines · On Mon, Nov 23, 2020 at 10:50 AM <[email protected]> wrote:

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=389671

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

Quoted 8 lines

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

Pushed.

Signature · 1 line
Luiz Augusto von Dentz