diff mbox series

[Bluez,v2,1/3] policy: add checks before connecting

Message ID 20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid
State New
Headers show
Series [Bluez,v2,1/3] policy: add checks before connecting | expand

Commit Message

Archie Pusaka Nov. 5, 2020, 6:29 a.m. UTC
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(+)

Comments

bluez.test.bot@gmail.com Nov. 5, 2020, 6:47 a.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=377909

---Test result---

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

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

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

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



---
Regards,
Linux Bluetooth
diff mbox series

Patch

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;