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=1796383437; b=Vg6fazzIifahilBATnWrdTubH4zAdNTtE/eMDjPwpfKgfERkgG4R6KFiY/rfWqe8BBGm MYE5Be487u+qtH1lv9FbhM9Ot6Mf5eiYFJTrC8FopRypesbQVOAi5nK9Xu50JzusPnUoj +8PJNRtfYYinUPQ+Zd1edE2aYwaEsudyJgFK0YBGBW8GA9g/axNcSTA6CoAZjRuag5hxm i5qPiPQW8TebymXpCuCPZClGt/kO/DgumAAD3v2dRINTDpEWv442EcG90vUFihMFVbUgp 3+SuE5STGgWFWNXKgkLtF6eevjywtpLixa5ZeFm5cf/pkVGV7HnhzMHYNNR0Vh5tcfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383437; 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=n830tV8u95CCL9yxaxqmnH/ROAA4opSyzpnBBy091JA=; b=v6keARvZ8equTnICysh1T4hDHT2l0ApoV6R8/SC0/aoBGWx7xLGptprt+UBB4APww9cq sqs+unun/i8/Pg2vrwk3PSzayicSkd1fedKXLS7G+KQgnoDmPrhGg0MIBoE0LtHJX1MiM yuyqT/WmXeWmhZGoMh9Y3EFtIktQxdvGIPLk8SxPb4N6Hw3Da1el7CGV620PZqrGRzX44 5km87IaeuVQ8o2fmi5Vh+KlqEYlxX860vDfCoccNVeZgxn7sy2zjsdf3WwYVneyPkhbdM 9Atv7zMTQUuxCnlfbCS9n8po/k5kUO9iord3D/I0RyJkfZK/0YiIIfvavwmUZffGckA== 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=ztUSAXAD; 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 337C2606A6B0; Fri, 4 Dec 2026 11:23:56 +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=ztUSAXAD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3853F1F00A0A; Fri, 4 Dec 2026 11:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383436; bh=n830tV8u95CCL9yxaxqmnH/ROAA4opSyzpnBBy091JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ztUSAXADUigOZE8yRBF1AzWxeleGJRV7gzRMI8xV+VjDeUS6Ff2oLLLKfRq8x+9GV 5yz2y34/ddw4R8hFyoDeis0e8vn928CiO/D7kHRLTqmMS223Jy8fx1ATKxlPU1B+Ft tPsx4pz//ztSB2XWktt7Peo7dTM4YJn8Po3lzNrM= 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 6.12 223/555] Bluetooth: MSFT: Record the filter state on Command Disallowed Date: Fri, 4 Dec 2026 19:04:26 +0900 Message-ID: <20261204100617.544639901@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 cd42b020c6c8d..e4597763e06c6 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