diff mbox series

[BlueZ] avdtp: Fix removing all remote SEPs when loading from cache

Message ID 20210311154036.1008199-1-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [BlueZ] avdtp: Fix removing all remote SEPs when loading from cache | expand

Commit Message

Luiz Augusto von Dentz March 11, 2021, 3:40 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If avdtp_discover is called after cache has been loaded it end up
removing all remote SEPs as they have not been discovered yet.

Fixes: https://github.com/bluez/bluez/issues/102
---
 profiles/audio/avdtp.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

bluez.test.bot@gmail.com March 11, 2021, 4:11 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=446379

---Test result---

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

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

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

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



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 088ca58b3..1d5871c62 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3381,10 +3381,18 @@  int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
 	session->discover = g_new0(struct discover_callback, 1);
 
 	if (session->seps) {
-		session->discover->cb = cb;
-		session->discover->user_data = user_data;
-		session->discover->id = g_idle_add(process_discover, session);
-		return 0;
+		struct avdtp_remote_sep *sep = session->seps->data;
+
+		/* Check that SEP have been discovered as it may be loaded from
+		 * cache.
+		 */
+		if (sep->discovered) {
+			session->discover->cb = cb;
+			session->discover->user_data = user_data;
+			session->discover->id = g_idle_add(process_discover,
+								session);
+			return 0;
+		}
 	}
 
 	err = send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0);