Diff between 942d7cb952ab0b7127988ad2c5b0b1d683326a07 and 2b06065bdd577c0043368d6101ca387c438988c2

Changed Files

File Additions Deletions Status
src/adapter.c +17 -0 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index c71dedc..e9bd981 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3733,6 +3733,23 @@ static void confirm_name(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
 	DBG("hci%d bdaddr %s name_known %u", adapter->dev_id, addr,
 								name_known);
 
+	/*
+	 * If the kernel does not answer the confirm name command with
+	 * a command complete or command status in time, this might
+	 * race against another device found event that also requires
+	 * to confirm the name. If there is a pending command, just
+	 * cancel it to be safe here.
+	 */
+	if (adapter->confirm_name_id > 0) {
+		warn("Found pending confirm name for hci%u", adapter->dev_id);
+		mgmt_cancel(adapter->mgmt, adapter->confirm_name_id);
+	}
+
+	if (adapter->confirm_name_timeout > 0) {
+		g_source_remove(adapter->confirm_name_timeout);
+		adapter->confirm_name_timeout = 0;
+	}
+
 	memset(&cp, 0, sizeof(cp));
 	bacpy(&cp.addr.bdaddr, bdaddr);
 	cp.addr.type = bdaddr_type;