From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 1/2] client/btpclient: Fix GAP unpair command
Date: Tue, 19 May 2026 10:50:15 +0200 [thread overview]
Message-ID: <20260519085016.188744-1-frederic.danis@collabora.com> (raw)
Fix unpair_reply() because the device is no more available on
RemoveDevice reply.
---
client/btpclient/gap.c | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/client/btpclient/gap.c b/client/btpclient/gap.c
index 68e029dcc..a14cd4795 100644
--- a/client/btpclient/gap.c
+++ b/client/btpclient/gap.c
@@ -2174,17 +2174,15 @@ failed:
btp_send_error(btp, BTP_GAP_SERVICE, index, status);
}
+struct unpair_req {
+ uint8_t index;
+ struct btp_device *device;
+};
+
static void unpair_reply(struct l_dbus_proxy *proxy,
struct l_dbus_message *result, void *user_data)
{
- struct btp_device *device = user_data;
- struct btp_adapter *adapter = find_adapter_by_device(device);
-
- if (!adapter) {
- btp_send_error(btp, BTP_GAP_SERVICE, BTP_INDEX_NON_CONTROLLER,
- BTP_ERROR_FAIL);
- return;
- }
+ struct unpair_req *req = user_data;
if (l_dbus_message_is_error(result)) {
const char *name, *desc;
@@ -2192,19 +2190,19 @@ static void unpair_reply(struct l_dbus_proxy *proxy,
l_dbus_message_get_error(result, &name, &desc);
l_error("Failed to unpair (%s), %s", name, desc);
- btp_send_error(btp, BTP_GAP_SERVICE, adapter->index,
- BTP_ERROR_FAIL);
+ btp_send_error(btp, BTP_GAP_SERVICE, req->index,
+ BTP_ERROR_FAIL);
return;
}
- btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, adapter->index, 0,
- NULL);
+ btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR, req->index, 0,
+ NULL);
}
static void unpair_setup(struct l_dbus_message *message, void *user_data)
{
- struct btp_device *device = user_data;
- const char *path = l_dbus_proxy_get_path(device->proxy);
+ struct unpair_req *req = user_data;
+ const char *path = l_dbus_proxy_get_path(req->device->proxy);
struct l_dbus_message_builder *builder;
builder = l_dbus_message_builder_new(message);
@@ -2223,6 +2221,7 @@ static void btp_gap_unpair(uint8_t index, const void *param, uint16_t length,
uint8_t status = BTP_ERROR_FAIL;
struct btp_device *device;
bool prop;
+ struct unpair_req *req;
if (!adapter) {
status = BTP_ERROR_INVALID_INDEX;
@@ -2237,14 +2236,21 @@ static void btp_gap_unpair(uint8_t index, const void *param, uint16_t length,
device = find_device_by_address(adapter, &cp->address,
cp->address_type);
- if (!device)
- goto failed;
+ if (!device) {
+ btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_UNPAIR,
+ adapter->index, 0,
+ NULL);
+ return;
+ }
/* There is no direct unpair method, removing device will clear pairing
* information.
*/
+ req = l_new(struct unpair_req, 1);
+ req->index = index;
+ req->device = device;
l_dbus_proxy_method_call(adapter->proxy, "RemoveDevice", unpair_setup,
- unpair_reply, device, NULL);
+ unpair_reply, req, l_free);
return;
--
2.43.0
next reply other threads:[~2026-05-19 8:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 8:50 Frédéric Danis [this message]
2026-05-19 8:50 ` [PATCH BlueZ v2 2/2] client/btpclient: Don't remove all devices on GAP Reset command Frédéric Danis
2026-05-19 12:23 ` [BlueZ,v2,1/2] client/btpclient: Fix GAP unpair command bluez.test.bot
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=20260519085016.188744-1-frederic.danis@collabora.com \
--to=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.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