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=1795618163; b=wJO09t/pZ0GCyLaPprmq44WLF1xumCJqR0Jo2YZBWGm1ngTdHP9wh66GsqZw6H7c3LBH lpUNGQIdryTQbvY+dGgolH4zA2LlKySeQ2m9AF9KGzryH5IFgiEpRMqeukV8qf5/ON5lp fKgp31SDCm1r05UF88dIF2pcPmgivFQAPfLNLoktUFSZmDhGWMUvzicRQAh0E4/1BF0EW xip9Py7B2XL18ogwLd1/vf2q8rEhECbrvPaPwodYvYorI55CrHoz4ljr0q//CZuu96F64 NJ8PUq1GKCBw41HWQwPF395hC/IHX9cPpfGw1sjneXAzX+1XOc4f+7lCkq3X1nVTZQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795618163; 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=ZuMpHpL1cQ0wZKzywovKd9Vvm7VqyXPNZsNAES/TbF4=; b=HSqC3bid17eynHxYTgUa5qovQ30+JDQ0TsyBvBcMf77c6l8E06Yt/ZfixWb9CnoVAI4c YUY40U4YgLVWX1DRea09I+2FXoIxpP082+solBFLjE6EOm/2ha2lwJWXY1m6RKON1bFUj mIXO/+KKW1uVrpR/MnNz1Xlyh6wmwGhSd0l6dzrLtrGNl5g45x9I1E0cI3fFZGWak5a2f fe8zL5MlcP8VmScuu4hAcdf00q99W5g0ey6VmomWHpuFz/epUTQT9cxrtM2im9qaPtGCI UFp7ale+EHjeiflXE8tFWaRiV/FNBnmrXG7T6soySbUtNsEMF2f/nS+ZEi6kR8X8XAA== 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=Vuw1P0n8; 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 5113F606A329; Wed, 25 Nov 2026 14:49:23 +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=Vuw1P0n8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A281B1F01570; Wed, 25 Nov 2026 14:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795618163; bh=ZuMpHpL1cQ0wZKzywovKd9Vvm7VqyXPNZsNAES/TbF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Vuw1P0n8YtBLljrX9XrmWm4TV6xCqcYANepz4DJ1m3VA1/VsPXrv0s2Be7DpR41+b Cfgf/XsDBgD6SlPYf3m0Wb+zywuxA2UnI4z1H8WGSVgYPkIubyNaFCcC1tCAWR3zE1 o0gl7vT6n4duXOnqdqJsOJf+mgTUFj3mg3h5D7PE= 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 7.3 0193/1005] Bluetooth: hci_event: Clear explicit connect state on LE connection Date: Wed, 25 Nov 2026 15:25:31 +0100 Message-ID: <20261125143826.261343977@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143821.729802100@linuxfoundation.org> References: <20261125143821.729802100@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 7.3-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 cf44452e0766e..8f136f28b7d68 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1586,8 +1586,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 3288f92fe41bf..f5c2bc77397b9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5956,6 +5956,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; + } + } } /* If we are central and have subrate parameters stored, queue a -- 2.53.0