From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796138939; b=j0pE3bWnfMJxXK8o5H1PIMuOeUtD2CYhak5I5Atfs+RLwwHWEMl/TMe517HBFScYTBTc +efO91LLekeBPMPQh8Vf6YfGQLW623va7BGfJlxzuvBHRTLiMpJhg7cileClpeLTB1mhV EJezMiujR0WMJgAB4kn5LoaKUHbBDacOeSSzmwn/swaniMxgPs9HCpNsflv6CFKQLjUq4 vEE5u6xRxygD1nNfNIRnBsinBU9vN24wOjOgWhFn905iL/GQUW4TpUXZ6bLE1HLhbEpVk cM1G7UGomnQ8V87BcosCCjutKLFbdIeRyvQeE73UdH+H1lSpqnoD7GImIL3Z7+oG0Rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796138939; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=9Sz7oZlVgRbdpFLiwz7qwppy3s6qmoayIRpCqoJoB20=; b=rB1bojkEJZ2iuKwA6SG5HwvFrAmcz3OG21mpIzOYI5kgKEc4k0DjChxNsUPzXq/Zh+y8 aMHMQpQOwr52omqXHmMo/ZGqKMoD1vQnWQSD9i3lTm1lczCVa49IxQWOg2gkYi3skQqmi lQOA0wVE2Si6aU5EgE7JP3oI61kVaWz0o74Fg3LIshjdTUDbvjfeR4d4Gu+vdmvV13EYC OfNEANcl0Kcjgf9TbQkRhldTxLDBrHv6xrEXHi0ilZigIvkYoFum0p8JRPxdzNv8qk5DC giO2Bz7is0N0qdOa81KFuRL/PsVriaZers1UtQbSYZUEJW8Ww/3eg4A+fLCBS+tLTmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Av6I8mYB; arc=none smtp.remote-ip=209.85.222.48 Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A12FF606A338 for ; Tue, 1 Dec 2026 15:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A12FF606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Av6I8mYB Received: by mail-ua1-f48.google.com with SMTP id a1e0cc1a2514c-99e1b352df9so3375086241.1 for ; Tue, 01 Dec 2026 07:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796138938; x=1796743738; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=9Sz7oZlVgRbdpFLiwz7qwppy3s6qmoayIRpCqoJoB20=; b=Av6I8mYBVsRnKg3m/5cwU3X/8Q1FHZJWYgjdTNvyslvK1raMTKX3wJPdI/SApmVklC 4LS3a5CdydidT7QVz7o3IKYd2y9SBSOx9wHAnODuLU1PaAFjFqeIot5fZLu+/DCS0da5 +inxPZn8nBAssR1oOg6wlG3hJS0gm9uXu2fS6HBgVvhXcjAotitnzkax9e+StKApJbOW HHUvTS/qGaLUL00avXoAhLWUiknmU6l4JQJLE1cSu2mnsQh+xnpcfrOWd/yvTzhm9/RD wxbQ4BN2Ug90D/WAvDg9VlF7AKKyOXANdDV8WnevN1/5xeJLH908OXs24Ph8rXj+RD55 aIzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796138938; x=1796743738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=9Sz7oZlVgRbdpFLiwz7qwppy3s6qmoayIRpCqoJoB20=; b=T1WTtnoLnKuTegT5cDAizLczI05cLLpEVzP+XBRQJ5JDcGwru9Td0+laklqfOEak83 ow1XhyimOYl6V5sqj8XA8iqR39Ie9h6owyUDJFP13f1T4ndo4u5CAvjYI4Lb+QpYfMRy jVzCCxSKX5ltWehrC431TjchANAMkg+Qn/33omNVLIOuuCAxuGGAE/FJt+/IDKj0d447 fEfj/ZdsFHgq3C16yPJqswHvufzhvh2tbSLgPiiAZi2rxKW0Vdb+3FkK7k1CKvDMGaVm eTK7R0SWSMWWcgW8gXgfBRlfEn+gz97UcWNvj0QV9FjvwaE88/AGEFhSjwyQY5Ryd9cj J02A== X-Gm-Message-State: APuU4Z+qVTGHIWeo6KrXEgvU+y833vFMoph4GHzajBfQQLeNavXKIup9 X+j0RdPpJeKHjvht/HXUEP6JQRZjJHN4fJZ4O8YybzcvNsS/fhGCgv/9kjSkghHMtSY= X-Gm-Gg: AZFdTZcFIld9QCC97F3izpr0kXY3HxS9imyfdMcpioiq5XoU0BkzOk39nzHAiIAXktn vLytOhRz1LNnfo6cafhaO4hpRPGUCAJ80vdereEfG7o6eVrb3vo0k50Kqvq/jTMzJLLMtgMFfdA PXsKkAW+OimSNTfo/+E5nuCvtm18ZIMes3I2agfeK02yGbsgsYd+Xtk6TUJ9JHFRiXookPw0Yh8 WlyoznfHlwMyiUoIH1L9DBW+DtBLgUUUvti74ec8Bw9txw1STP6W6SWKBG9D87aW5H6Z+5i9uuA KbEQ81G+3+g2gyzJ9uDnwelpenpl3xklrwW3teD35HcSMILy7dIFTv9tZboBvdVq4OKJhPyITJF vP6cysAJlstYykFJRFQTHA7G/Dzjhx9ezrGsG4u8XqznS6L5274W+Yq5SHhRIUY06Q0FNVg6GnL Qx4vB90oZicGHWdEnNqsNjrYOw1gdtYOrUmVpFck/5e7Pz7mBM4KcLflnh4piYmdQx5ihlpPFCs BXA+UMzy4IrrQiZEQeHA34aeCiDWYuENnGMVbc9c2NFPGoZlXzPiVvo/ydHNg9W+T6hQfjWrFyD OvE3j9PAe/k2p+NcBY04Ij5o4ESXG0IWeeMGWhyoZhs36SEWZ7hdHEZa34NKLOgisstXJNLNzko bAcVpQldut+p9YHAE+HMlWE87Dgvp+6viagup/OM/ECV3YCHpcd4oRtfs/6gX1y43kWkedLlVLJ U/GH8= X-Received: by 2002:a05:6122:513:b0:5ee:3fae:3995 with SMTP id 71dfb90a1353d-5ee8af737dcmr24132575e0c.22.1796138937448; Tue, 01 Dec 2026 07:28:57 -0800 (PST) Received: from lvondent-mobl5.taila91cb8.ts.net ([72.188.211.115]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-99e6df8a29csm37603297241.5.2026.12.01.07.28.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:28:56 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v11 2/6] Bluetooth: L2CAP: Fix deferred LE channels being disconnected once accepted Date: Tue, 1 Dec 2026 10:28:49 -0500 Message-ID: <20261201152853.1118148-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201152853.1118148-1-luiz.dentz@gmail.com> References: <20261201152853.1118148-1-luiz.dentz@gmail.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz When userspace authorizes a deferred LE Credit Based or Enhanced Credit Based channel, l2cap_sock_defer() moves it to BT_CONNECTED directly instead of with l2cap_chan_ready(), so the timer armed when the request was received is not stopped and CONF_NOT_COMPLETE is not cleared. The timer then fires on the established channel and disconnects it, and since CONF_NOT_COMPLETE is still set l2cap_chan_del() returns before purging its tx queue. Fix this by completing LE Credit Based channels with l2cap_chan_ready() once the response is sent, as done for the ones that are not deferred. Enhanced Credit Based channels stay in BT_CONNECTED while the response of their request is pending, so their timer is stopped when they are authorized, as only the channels still pending shall time out, and the rest of what l2cap_chan_ready() does is done once the response is sent. Fixes: 27e2d4c8d28b ("Bluetooth: Add basic LE L2CAP connect request receiving support") Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Assisted-by: OpenCode:claude-fable-5.2 Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/l2cap_core.c | 18 ++++++++++++++++-- net/bluetooth/l2cap_sock.c | 6 ++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 943effc86740..411b26b3de72 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4042,6 +4042,11 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan) l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp), &rsp); chan->ident = 0; + + /* The response establishes the channel, which also stops its timer + * and completes its configuration like for one that is not deferred. + */ + l2cap_chan_ready(chan); } static void l2cap_ecred_list_defer(struct l2cap_chan *chan, void *data) @@ -4145,10 +4150,19 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data) rsp->pdu.rsp.result = cpu_to_le16(L2CAP_CR_LE_NO_MEM); /* Include all channels pending with the same ident */ - if (!rsp->pdu.rsp.result) + if (!rsp->pdu.rsp.result) { rsp_flex->dcid[rsp->count++] = cpu_to_le16(chan->scid); - else + + /* The response establishes the channel, which was already + * moved to BT_CONNECTED when userspace authorized it, so + * complete what l2cap_chan_ready() does. + */ + chan->conf_state = 0; + if (!chan->tx_credits) + chan->ops->suspend(chan); + } else { l2cap_chan_del(chan, ECONNRESET); + } done: if (locked) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index d5663a4642a9..c1603495aab3 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1288,10 +1288,12 @@ static int l2cap_sock_defer(struct sock *sk) sk->sk_state = BT_CONNECTED; chan->state = BT_CONNECTED; release_sock(sk); + /* The channel is accepted, only the ones still pending + * shall time out while waiting for the response. + */ + __clear_chan_timer(chan); __l2cap_ecred_conn_rsp_defer(chan); } else if (bdaddr_type_is_le(chan->src_type)) { - sk->sk_state = BT_CONNECTED; - chan->state = BT_CONNECTED; release_sock(sk); __l2cap_le_connect_rsp_defer(chan); } else { -- 2.56.0