From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386987; b=uTkaPlXW5plbXMJFg9OuIHjQFR2Lz7zoI9degTiwqWNik2odoTNqTBO8vKAWCVBK82CJ peUSGD57oJIMATpWcPvnrjSk9EJ0Uy4BNmdCWPtxFwgqOzeEengNAQ5hSYRYues8Zr1om 72NFb9yLQvsaou34oZ6pfT2Z077GIJ5eKUrgwJKH2mfPhLIfRO6cMQONN4QMwhMNaCy2w hptXtSyHCBzwcD/Gi8WG4wfRvsdtoXuKRGkZOHTyiW27GY+uPRG4DB1ofHh2mPq2Y3DZ6 1ODhbmxIQarRGMkZNrMPIwCgv7tSoJfQH+0vJ6XRiKuOX5HR1aKLI6xeUa33l7Vcw4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386987; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=LW6ols9TKb3DqD2bQQZNbcR7ILDFiT/gZlFLcU6+Y0Y=; b=t19viDdW7XbdSUgwKaX1n4OzdV2zyy585p7uBKgXHXgxZzN3FKJzeQSvJs4eIq5Ir1pG dA/DAgA+6lCUtNLq0f4Mqg3dTgTy0PgFFofwB69iAP0ZSWnD7l+DZGwW6Ut/N7syKulLg RTfg7BsheaFBQSY0nIX7ynqKj5w8ZXJCR2cqCCHOSOctoABB6cLd49FqcJJyD8rpyYXyQ fh7mmv3uecOVbW95XCz84ifn/ha65a+AdHWholkw1/q2Ko0z8uXlEDAlpkICmrs90fU9S H60uJaAXEeQcjAp9cShaDz2SbvWRWZD3S59BQuHWvtXYFOBnwBfT4eGLTWl9ZSWfR+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=TJzaxSbc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04D9D606A322; Fri, 4 Dec 2026 12:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=TJzaxSbc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 758DB1F000CE; Fri, 4 Dec 2026 12:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386986; bh=LW6ols9TKb3DqD2bQQZNbcR7ILDFiT/gZlFLcU6+Y0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TJzaxSbcvJqlgFqMBWKk8gY9GSKHv2J1rIKH+fvxLYO38dzoORmzJJz5WyBZHQjtC hUoEOLxKOO5E4THViko6ZNwBdHY5+njqheyrfUE8bHlTOmlE87ROmgx1U6l8geDsq3 pZwoMz94ZyWcSVHENRCtd/XgcvI5C3YNrFBigl2s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kevin Dewald , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.1 0085/1059] Bluetooth: hci_event: Clear explicit connect state on LE connection Date: Fri, 4 Dec 2026 18:53:36 +0900 Message-ID: <20261204100646.313860899@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kevin Dewald [ Upstream commit f5cd268af1c6f87fb3847e98274e22b8c6324aa4 ] Since commit 6cd29ec6ae5e ("Bluetooth: hci_sync: Wait for proper events when connecting LE"), create_le_conn_complete() only runs once the LE Connection Complete event has been handled, and le_conn_complete_evt() has already removed the connection parameters from pend_le_conns by then. hci_connect_le_scan_cleanup() looks the parameters up in pend_le_conns, so after a successful connection it no longer clears explicit_connect, nor deletes the parameters that were only created for the explicit connect. The parameters of every device connected through an explicit connect, such as an L2CAP or ATT connect or MGMT Pair Device, are thus left with explicit_connect set. MGMT Remove Device for all devices then keeps them as HCI_AUTO_CONN_EXPLICIT instead of freeing them, and if the device was set to auto-connect and is disconnected, they also stay on pend_le_conns: the kernel keeps scanning for the device and connects to it as soon as it advertises, although no one asked for it any more. Do the cleanup in le_conn_complete_evt() instead, where the explicit connect request is fulfilled: clear explicit_connect, delete the parameters if they only existed for it, and put report parameters back on pend_le_reports. Auto-connect parameters are added back to pend_le_conns on disconnection, as before. Update the comment in hci_explicit_conn_params_set() that names hci_connect_le_scan_cleanup() as the only place deleting them. Fixes: 6cd29ec6ae5e ("Bluetooth: hci_sync: Wait for proper events when connecting LE") Assisted-by: Claude:claude-opus-5.5 Signed-off-by: Kevin Dewald Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_conn.c | 5 +++-- net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 0c0c052294fc7..327c73431fb96 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1476,8 +1476,9 @@ static int hci_explicit_conn_params_set(struct hci_dev *hdev, if (!params) return -ENOMEM; - /* If we created new params, mark them to be deleted in - * hci_connect_le_scan_cleanup. It's different case than + /* If we created new params, mark them to be deleted once the + * explicit connect is done, see le_conn_complete_evt() and + * hci_connect_le_scan_cleanup(). It's different case than * existing disabled params, those will stay after cleanup. */ params->auto_connect = HCI_AUTO_CONN_EXPLICIT; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 1fd012fa118f4..26b859c2c9c58 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5839,6 +5839,28 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, hci_conn_put(params->conn); params->conn = NULL; } + + /* An explicit connect request is complete once connected, so + * clean it up here: hci_connect_le_scan_cleanup() no longer + * finds the params since they have just been removed from + * pend_le_conns. + */ + if (params->explicit_connect) { + params->explicit_connect = false; + + switch (params->auto_connect) { + case HCI_AUTO_CONN_EXPLICIT: + hci_conn_params_del(hdev, &conn->dst, + conn->dst_type); + break; + case HCI_AUTO_CONN_REPORT: + hci_pend_le_list_add(params, + &hdev->pend_le_reports); + break; + default: + break; + } + } } unlock: -- 2.53.0