From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/2] btdev: Fix double lookup
Date: Tue, 11 Mar 2025 15:42:26 -0400 [thread overview]
Message-ID: <20250311194226.15109-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20250311194226.15109-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes the existing double lookup when calling
num_completed_packets but passing the conn->handle instead of passing
the conn pointer directly since num_completed_packets would then attempt
to do another lookup by handle to resolve the conn pointer again.
---
emulator/btdev.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 976c1125d66e..1b7b75c21399 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -7460,21 +7460,15 @@ void btdev_set_send_handler(struct btdev *btdev, btdev_send_func handler,
btdev->send_data = user_data;
}
-static void num_completed_packets(struct btdev *btdev, uint16_t handle)
+static void num_completed_packets(struct btdev *btdev, struct btdev_conn *conn)
{
- struct btdev_conn *conn;
+ struct bt_hci_evt_num_completed_packets ncp;
- conn = queue_find(btdev->conns, match_handle, UINT_TO_PTR(handle));
- if (conn) {
- struct bt_hci_evt_num_completed_packets ncp;
+ ncp.num_handles = 1;
+ ncp.handle = cpu_to_le16(conn->handle);
+ ncp.count = cpu_to_le16(1);
- ncp.num_handles = 1;
- ncp.handle = cpu_to_le16(handle);
- ncp.count = cpu_to_le16(1);
-
- send_event(btdev, BT_HCI_EVT_NUM_COMPLETED_PACKETS,
- &ncp, sizeof(ncp));
- }
+ send_event(btdev, BT_HCI_EVT_NUM_COMPLETED_PACKETS, &ncp, sizeof(ncp));
}
static const struct btdev_cmd *run_cmd(struct btdev *btdev,
@@ -7672,7 +7666,7 @@ static void send_acl(struct btdev *dev, const void *data, uint16_t len)
if (!conn)
return;
- num_completed_packets(dev, conn->handle);
+ num_completed_packets(dev, conn);
/* ACL_START_NO_FLUSH is only allowed from host to controller.
* From controller to host this should be converted to ACL_START.
@@ -7709,7 +7703,7 @@ static void send_sco(struct btdev *dev, const void *data, uint16_t len)
return;
if (dev->sco_flowctl)
- num_completed_packets(dev, conn->handle);
+ num_completed_packets(dev, conn);
if (conn->link)
send_packet(conn->link->dev, iov, 2);
@@ -7734,7 +7728,7 @@ static void send_iso(struct btdev *dev, const void *data, uint16_t len)
if (!conn)
return;
- num_completed_packets(dev, conn->handle);
+ num_completed_packets(dev, conn);
if (conn->link)
send_packet(conn->link->dev, iov, 2);
--
2.48.1
next prev parent reply other threads:[~2025-03-11 19:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 19:42 [PATCH BlueZ v1 1/2] sco-tester: Fix closing the socket Luiz Augusto von Dentz
2025-03-11 19:42 ` Luiz Augusto von Dentz [this message]
2025-03-11 21:11 ` [BlueZ,v1,1/2] " bluez.test.bot
2025-03-12 14:40 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
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=20250311194226.15109-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.