From: Jiale Yao <yaojiale02@163.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiale Yao <yaojiale02@163.com>
Subject: [PATCH 2/2] Bluetooth: msft: free detached address filter on cancel
Date: Sat, 17 Oct 2026 11:10:22 +0800 [thread overview]
Message-ID: <20261017031022.3616384-1-yaojiale02@163.com> (raw)
An address filter queued for addition can be detached from the MSFT
filter list and marked AF_STATE_REMOVING before its command-sync work
runs. If the queued entry is then cancelled, its NULL destroy callback
leaves the detached filter without an owner.
Install a destroy callback that frees a cancelled filter only when it
has reached AF_STATE_REMOVING. Filters that are still linked remain
owned by the normal close cleanup path.
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
net/bluetooth/msft.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index d9dd722db3eb..b9f8f089cc72 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -928,6 +928,16 @@ static int msft_add_address_filter_sync(struct hci_dev *hdev, void *data)
return 0;
}
+static void msft_add_address_filter_destroy(struct hci_dev *hdev, void *data,
+ int err)
+{
+ struct msft_monitor_addr_filter_data *address_filter = data;
+
+ if (err == -ECANCELED &&
+ address_filter->state == AF_STATE_REMOVING)
+ kfree(address_filter);
+}
+
/* This function requires the caller holds msft->filter_lock */
static struct msft_monitor_addr_filter_data *msft_add_address_filter
(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr,
@@ -959,7 +969,7 @@ static struct msft_monitor_addr_filter_data *msft_add_address_filter
list_add_tail(&address_filter->list, &msft->address_filters);
err = hci_cmd_sync_queue(hdev, msft_add_address_filter_sync,
- address_filter, NULL);
+ address_filter, msft_add_address_filter_destroy);
if (err < 0) {
bt_dev_err(hdev, "MSFT: Add address %pMR filter err", bdaddr);
list_del(&address_filter->list);
--
2.34.1
next reply other threads:[~2026-10-17 3:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 3:10 Jiale Yao [this message]
2026-10-17 7:37 ` jiale yao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261017031022.3616384-1-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®