linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez PATCH v1] adapter: Don't remove device if adapter is powered off
@ 2020-12-29  6:34 Archie Pusaka
  2020-12-29  6:44 ` [Bluez,v1] " bluez.test.bot
  2021-01-04 19:09 ` [Bluez PATCH v1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 7+ messages in thread
From: Archie Pusaka @ 2020-12-29  6:34 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz
  Cc: CrosBT Upstreaming, Archie Pusaka, Daniel Winkler

From: Archie Pusaka <apusaka@chromium.org>

If adapter is powered off when a device is being removed, there is a
possibility that the kernel couldn't clean the device's information,
for example the pairing information. This causes the kernel to
disagree with the user space about whether the device is paired.

Therefore, to avoid discrepancy we must not proceed to remove the
device within the user space as well.

Reviewed-by: Daniel Winkler <danielwinkler@google.com>
---

 src/adapter.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index ec6a6a64c5..a2abc46706 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1238,6 +1238,14 @@ void btd_adapter_remove_device(struct btd_adapter *adapter,
 {
 	GList *l;
 
+	/* Test if adapter is or will be powered off.
+	 * This is to prevent removing the device information only on user
+	 * space, but failing to do so on the kernel.
+	 */
+	if (!(adapter->current_settings & MGMT_SETTING_POWERED) ||
+			(adapter->pending_settings & MGMT_SETTING_POWERED))
+		return;
+
 	adapter->connect_list = g_slist_remove(adapter->connect_list, dev);
 
 	adapter->devices = g_slist_remove(adapter->devices, dev);
-- 
2.29.2.729.g45daf8777d-goog


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

end of thread, other threads:[~2021-01-06  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29  6:34 [Bluez PATCH v1] adapter: Don't remove device if adapter is powered off Archie Pusaka
2020-12-29  6:44 ` [Bluez,v1] " bluez.test.bot
2021-01-04 19:09 ` [Bluez PATCH v1] " Luiz Augusto von Dentz
2021-01-04 19:16   ` Luiz Augusto von Dentz
2021-01-05  3:17     ` Archie Pusaka
2021-01-05 18:33       ` Luiz Augusto von Dentz
2021-01-06  9:29         ` Archie Pusaka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).