Skip to contentSkip to conversation

a2dp: Fix crash on transport_cb

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Jun 1, 2020 – Jun 2, 2020 1 message not in the archive Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 a2dp: Fix crash on transport_cb

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

There have been reports of crashes on transport_cb where the setup would most likely already have been freed but transport_cb would still be called, so instead of assuming the setup pointer would be valid try to lookup the list of active setups and log a warning when it happens.

---
 profiles/audio/a2dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
profiles/audio/a2dp.c +8 -0
index 7f14c880a..d88d1fa69 100644
@@ -2217,6 +2217,14 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
 	struct a2dp_setup *setup = user_data;
 	uint16_t omtu, imtu;
+	GSList *l;
+
+	l = g_slist_find(setups, setup);
+	if (!l) {
+		warn("bt_io_accept: setup %p no longer valid", setup);
+		g_io_channel_shutdown(io, TRUE, NULL);
+		return;
+	}
 
 	if (err) {
 		error("%s", err->message);
Signature · 1 line
2.25.3

A message that is not in the archive (sent off-list or not yet received): CALWDO_UDqCm_tgA5aGyeRz=GDQYFnS+UC-AJ3h2NjGfJCSSwLw@mail.gmail.com

author maintainer
#2 lore raw

Hi,

Quoted 36 lines · Alain Michaud

Hi Luiz,

Quoted 7 lines · On Mon., Jun. 1, 2020, 5:39 p.m. Luiz Augusto von Dentz…

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

There have been reports of crashes on transport_cb where the setup would most likely already have been freed but transport_cb would still be called, so instead of assuming the setup pointer would be valid try to lookup the list of active setups and log a warning when it happens.

Quoted 22 lines
---
 profiles/audio/a2dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
profiles/audio/a2dp.c +8 -0
index 7f14c880a..d88d1fa69 100644
@@ -2217,6 +2217,14 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
        struct a2dp_setup *setup = user_data;
        uint16_t omtu, imtu;
+       GSList *l;
+
+       l = g_slist_find(setups, setup);
+       if (!l) {
+               warn("bt_io_accept: setup %p no longer valid", setup);
+               g_io_channel_shutdown(io, TRUE, NULL);
+               return;
+       }
 
Quoted 4 lines
Quoted 4 lines
profiles/audio/a2dp.c +0 -1
        if (err) {
                error("%s", err->message);
--

2.25.3

Pushed.

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

Thanks Luiz!

Quoted 49 lines · Luiz Augusto von Dentz

Hi,

Quoted 36 lines · Alain Michaud

Hi Luiz,

Quoted 7 lines · On Mon., Jun. 1, 2020, 5:39 p.m. Luiz Augusto von Dentz…

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

There have been reports of crashes on transport_cb where the setup would most likely already have been freed but transport_cb would still be called, so instead of assuming the setup pointer would be valid try to lookup the list of active setups and log a warning when it happens.

Quoted 22 lines
---
 profiles/audio/a2dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
profiles/audio/a2dp.c +8 -0
index 7f14c880a..d88d1fa69 100644
@@ -2217,6 +2217,14 @@ static void transport_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
        struct a2dp_setup *setup = user_data;
        uint16_t omtu, imtu;
+       GSList *l;
+
+       l = g_slist_find(setups, setup);
+       if (!l) {
+               warn("bt_io_accept: setup %p no longer valid", setup);
+               g_io_channel_shutdown(io, TRUE, NULL);
+               return;
+       }
 
Quoted 4 lines
Quoted 4 lines
profiles/audio/a2dp.c +0 -1
        if (err) {
                error("%s", err->message);
--

2.25.3

Pushed.

--
Luiz Augusto von Dentz