a2dp: Fix crash when SEP codec has not been initialized
Luiz Augusto von Dentz
maintainerPATCH v4 1/1 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 when running AVRCP/TG/VLH/BI-01-C after AVRCP/TG/RCR/BV-04-C
---
v4: remove queue_isempty check from store_remote_seps since that prevents cleaning up if no seps could be registered.
profiles/audio/a2dp.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
profiles/audio/a2dp.c +17 -5
@@ -829,9 +829,6 @@ static void store_remote_seps(struct a2dp_channel *chan)char *data;gsize length =0 ; -if (queue_isempty (chan->seps)) -return ; -ba2str (device_get_address (device), dst_addr); snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s",
@@ -2074,6 +2071,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;
@@ -2148,6 +2150,7 @@ static void load_remote_sep(struct a2dp_channel *chan, GKeyFile *key_file,struct avdtp_remote_sep *rsep;uint8_t lseid, rseid;char *value; +bool update = false;if (!seids)return ;
@@ -2206,10 +2209,19 @@ 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 = true; +continue ; + } + + sep->from_cache = true; } +/* Update cache */ +if (update) +store_remote_seps (chan); + value =g_key_file_get_string (key_file,"Endpoints" ,"LastUsed" ,NULL );if (!value)return ;
Signature · 1 line
2.35.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=627319
---Test result---
Test Summary:
CheckPatch PASS 0.66 seconds GitLint PASS 0.44 seconds Prep - Setup ELL PASS 45.94 seconds Build - Prep PASS 0.61 seconds Build - Configure PASS 8.87 seconds Build - Make PASS 1623.11 seconds Make Check PASS 12.49 seconds Make Check w/Valgrind PASS 499.49 seconds Make Distcheck PASS 256.95 seconds Build w/ext ELL - Configure PASS 9.23 seconds Build w/ext ELL - Make PASS 1636.91 seconds Incremental Build with patchesPASS 0.00 seconds
---
Regards,
Linux Bluetooth