All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez PATCH v2 1/3] policy: add checks before connecting
@ 2020-11-05  6:29 Archie Pusaka
  2020-11-05  6:29 ` [Bluez PATCH v2 2/3] audio: unref session when failed to setup Archie Pusaka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Archie Pusaka @ 2020-11-05  6:29 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz; +Cc: CrosBT Upstreaming, Archie Pusaka

From: Archie Pusaka <apusaka@chromium.org>

When policy_connect() is called, there might be a case where the
device is not ready, or even the adapter is down. Add some checks
by calling btd_device_connect_services() instead of directly calling
btd_service_connect().
---

Changes in v2:
* Add adapter status check in btd_service_connect() instead of using
  btd_device_connect_services()

 src/service.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/service.c b/src/service.c
index d810fc3b05..21a52762e6 100644
--- a/src/service.c
+++ b/src/service.c
@@ -229,6 +229,9 @@ int btd_service_connect(struct btd_service *service)
 	if (!profile->connect)
 		return -ENOTSUP;
 
+	if (!btd_adapter_get_powered(device_get_adapter(service->device)))
+		return -ENETDOWN;
+
 	switch (service->state) {
 	case BTD_SERVICE_STATE_UNAVAILABLE:
 		return -EINVAL;
-- 
2.29.1.341.ge80a0c044ae-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Bluez PATCH v2 2/3] audio: unref session when failed to setup
  2020-11-05  6:29 [Bluez PATCH v2 1/3] policy: add checks before connecting Archie Pusaka
@ 2020-11-05  6:29 ` Archie Pusaka
  2020-11-05  6:29 ` [Bluez PATCH v2 3/3] audio/avdtp: Report failure in disconnected state Archie Pusaka
  2020-11-05  6:47 ` [Bluez,v2,1/3] policy: add checks before connecting bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: Archie Pusaka @ 2020-11-05  6:29 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz
  Cc: CrosBT Upstreaming, Archie Pusaka, Sonny Sasaka

From: Archie Pusaka <apusaka@chromium.org>

There is a possibility to miss unref-ing when source/sink fails at
setup.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
---

(no changes since v1)

 profiles/audio/sink.c   | 5 ++++-
 profiles/audio/source.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index 134d157bc6..d672670e25 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
@@ -258,8 +258,11 @@ gboolean sink_setup_stream(struct btd_service *service, struct avdtp *session)
 
 	sink->connect_id = a2dp_discover(sink->session, discovery_complete,
 								sink);
-	if (sink->connect_id == 0)
+	if (sink->connect_id == 0) {
+		avdtp_unref(sink->session);
+		sink->session = NULL;
 		return FALSE;
+	}
 
 	return TRUE;
 }
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index fca85d4cb3..c706c928a7 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
@@ -259,8 +259,11 @@ gboolean source_setup_stream(struct btd_service *service,
 
 	source->connect_id = a2dp_discover(source->session, discovery_complete,
 								source);
-	if (source->connect_id == 0)
+	if (source->connect_id == 0) {
+		avdtp_unref(source->session);
+		source->session = NULL;
 		return FALSE;
+	}
 
 	return TRUE;
 }
-- 
2.29.1.341.ge80a0c044ae-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Bluez PATCH v2 3/3] audio/avdtp: Report failure in disconnected state
  2020-11-05  6:29 [Bluez PATCH v2 1/3] policy: add checks before connecting Archie Pusaka
  2020-11-05  6:29 ` [Bluez PATCH v2 2/3] audio: unref session when failed to setup Archie Pusaka
@ 2020-11-05  6:29 ` Archie Pusaka
  2020-11-05  6:47 ` [Bluez,v2,1/3] policy: add checks before connecting bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: Archie Pusaka @ 2020-11-05  6:29 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz
  Cc: CrosBT Upstreaming, Archie Pusaka, Sonny Sasaka

From: Archie Pusaka <apusaka@chromium.org>

A2DP are relying on the disconnected state callback to do cleanup.
If failure occurs when AVDTP are already in the disconnected state,
we didn't make any transition state, therefore A2DP would miss this
event.

This patch allows the transition to disconnected state, even though
we are previously already in the disconnected state.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
---

(no changes since v1)

 profiles/audio/avdtp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 4c39088b8f..16fa20bba7 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2612,6 +2612,11 @@ static int send_req(struct avdtp *session, gboolean priority,
 	if (session->state == AVDTP_SESSION_STATE_DISCONNECTED) {
 		session->io = l2cap_connect(session);
 		if (!session->io) {
+			/* Report disconnection anyways, as the other layers
+			 * are using this state for cleanup.
+			 */
+			avdtp_set_state(session,
+					AVDTP_SESSION_STATE_DISCONNECTED);
 			err = -EIO;
 			goto failed;
 		}
-- 
2.29.1.341.ge80a0c044ae-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [Bluez,v2,1/3] policy: add checks before connecting
  2020-11-05  6:29 [Bluez PATCH v2 1/3] policy: add checks before connecting Archie Pusaka
  2020-11-05  6:29 ` [Bluez PATCH v2 2/3] audio: unref session when failed to setup Archie Pusaka
  2020-11-05  6:29 ` [Bluez PATCH v2 3/3] audio/avdtp: Report failure in disconnected state Archie Pusaka
@ 2020-11-05  6:47 ` bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2020-11-05  6:47 UTC (permalink / raw)
  To: linux-bluetooth, apusaka

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

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

---Test result---

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

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

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

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



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-05  6:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  6:29 [Bluez PATCH v2 1/3] policy: add checks before connecting Archie Pusaka
2020-11-05  6:29 ` [Bluez PATCH v2 2/3] audio: unref session when failed to setup Archie Pusaka
2020-11-05  6:29 ` [Bluez PATCH v2 3/3] audio/avdtp: Report failure in disconnected state Archie Pusaka
2020-11-05  6:47 ` [Bluez,v2,1/3] policy: add checks before connecting bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.