[PATCH 1/2] Bluetooth: MSFT: Record the filter state on Command Disallowed
From: Thomas de Gruijter via B4 Relay
Date: Thu Nov 19 2026 - 20:13:52 EST
From: Thomas de Gruijter <thomasdegruijter@xxxxx>
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 <thomasdegruijter@xxxxx>
---
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 7a06c2b8974b..f372df9a9831 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.56.0