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=1796380191; b=x21suCaR4LkcLb53F1KqS5ZBDrnxsPF2Jn2gSQ5dbBSfpEjXxVmZ8GLyslSSPkiuhSca 45yejZ48tOkFj1uFsTkN/arfBKoFVFbC0EMjQR0gN+VxQJOicyTEFIdmGUCXiutm0SMAv fEiPAPRcl0ryFMlg6GLKa3nPXbsLxgLWU3k4kftRZ0uQuA2bonL31VoQ3TQTMSqOFEXaJ qh0BWILuk1lvqN9qryI966YmL03G6DYxkl+Cv3QwzpytvnIx+w5lku+cszOYhu+VBdxMY EPNWDTFZgvmtL4HEAfYmaEQFQE2WLDKY24L/N7NonauVpPFhx/PYfNnHyLKfqt0i6gg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380191; 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=ElrohhXMh+f8MU4K18BNt/iMBFYp37v1kW7zKBIRxcU=; b=Tj2KGLWjwgY5ll/hab1CVQSOFdGj+lgzT4aXpTqMEfhr/mL0QDPPKFNAjG120tWf+BX/ z7gONBOIR9wxYk7CkM9qWdur8noUv9jOueMXWsQiRCOjtbS9ZNlEUmO8j4fOp/uWkLCEc b2TTmE0V7Akq6ey08x//y5SOMSY2yG609BxOMfEdjZx/VcppX7TbuOj4PlmbgN7BYmDpE qZCgs+a2/tfkz3pxsuaZDy//i+fIEtsS4BDTKs0M0dsJT8EomOJT/Bebq2I0QBujjnpHP uSzuekbgvvIro3bCiyWLAueXJV6lAXISICCVeVISZXcnGkXm5pcf1/GPDP4Sa2MhpsA== 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=mxvmiHE9; 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 35ED4606A33B; Fri, 4 Dec 2026 10:29:51 +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=mxvmiHE9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A19801F00936; Fri, 4 Dec 2026 10:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380191; bh=ElrohhXMh+f8MU4K18BNt/iMBFYp37v1kW7zKBIRxcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mxvmiHE9m8CAFRIV+EHenE4MkegyGVss502qgT8dEOZEyY0JA/wETPLp8mqkQZLbC CBExV8sXKwqzes8zzSbHv2LBehE7bShBhEZESsKdS46b1PIoJEuIoEU9uJgc04EfLc T3Wgrf94wzEFIIiUfIUve2Bl6leofhB5akTxBiig= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas de Gruijter , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 7.3 165/742] Bluetooth: MSFT: Record the filter state on Command Disallowed Date: Fri, 4 Dec 2026 19:00:29 +0900 Message-ID: <20261204100639.489857877@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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: Thomas de Gruijter [ Upstream commit 75d6b9d82c35d35dad9fdd783975be1edd32fe2f ] msft_le_set_advertisement_filter_enable_cb() treats status 0x0C (Command Disallowed) as success: a controller returns it when the advertisement filter is already in the requested state, and some controllers start with the filter enabled. Since commit 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to hci_sync") the callback is passed the return value of __hci_cmd_sync_status() instead of the HCI status. That function reports Command Disallowed as -EBUSY, so the 0x0C branch is never taken and msft->filter_enabled keeps its old value whenever the filter was already in the requested state. msft_set_filter_enable() also always returns 0, hiding real errors from its callers. Pass the error code to the callback, treat -EBUSY as the filter already being in the requested state, and return real errors from msft_set_filter_enable(). Nothing reads msft->filter_enabled yet, but the next patch relies on it to decide when to change the filter state. The problem was found, with the help of an AI coding assistant (Claude Code with Claude Opus 5.5). Fixes: 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to hci_sync") Signed-off-by: Thomas de Gruijter Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/msft.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c index 7a06c2b8974b7..f372df9a98311 100644 --- a/net/bluetooth/msft.c +++ b/net/bluetooth/msft.c @@ -1142,26 +1142,27 @@ __u64 msft_get_features(struct hci_dev *hdev) static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev, void *user_data, - u8 status) + int err) { struct msft_cp_le_set_advertisement_filter_enable *cp = user_data; struct msft_data *msft = hdev->msft_data; - /* Error 0x0C would be returned if the filter enabled status is + /* Error 0x0C (Command Disallowed), which __hci_cmd_sync_status() + * reports as -EBUSY, would be returned if the filter enabled status is * already set to whatever we were trying to set. * Although the default state should be disabled, some controller set * the initial value to enabled. Because there is no way to know the * actual initial value before sending this command, here we also treat * error 0x0C as success. */ - if (status != 0x00 && status != 0x0C) + if (err && err != -EBUSY) return; hci_dev_lock(hdev); msft->filter_enabled = cp->enable; - if (status == 0x0C) + if (err == -EBUSY) bt_dev_warn(hdev, "MSFT filter_enable is already %s", cp->enable ? "on" : "off"); @@ -1212,7 +1213,7 @@ int msft_set_filter_enable(struct hci_dev *hdev, bool enable) msft_le_set_advertisement_filter_enable_cb(hdev, &cp, err); - return 0; + return err == -EBUSY ? 0 : err; } bool msft_curve_validity(struct hci_dev *hdev) -- 2.53.0