* [PATCH] Bluetooth: btintel_pcie: fix context analysis error in YoYo config sets
@ 2026-11-26 0:04 Rosen Penev
2026-11-26 3:42 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-11-26 0:04 UTC (permalink / raw)
To: linux-bluetooth
Cc: Marcel Holtmann, Luiz Augusto von Dentz, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Kiran K,
open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b
btintel_pcie_apply_yoyo_config_sets() takes mac_access_lock only for
PERIPH_MAC and DEVICE_MEM config sets, writes the pairs, and later drops
the lock under a second, identical type check. Clang's context analysis
cannot correlate the two conditions, so with CONTEXT_ANALYSIS enabled for
drivers/bluetooth the build fails:
drivers/bluetooth/btintel_pcie.c:1052:12: error: mutex 'data->mac_access_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
drivers/bluetooth/btintel_pcie.c:1110:4: error: releasing mutex 'data->mac_access_lock' that was not held [-Werror,-Wthread-safety-analysis]
Move the pair-writing loop into a helper and take and release the lock
within a single switch case for the indirect config set types. No
functional change.
Fixes: 5bf3a9b6b720 ("Bluetooth: btintel_pcie: Serialize MAC access requests")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/bluetooth/btintel_pcie.c | 159 +++++++++++++++----------------
1 file changed, 79 insertions(+), 80 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index d7d0e890dfbb..7cbf6d2df491 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -997,6 +997,70 @@ static void btintel_pcie_yoyo_send_hcmds(struct btintel_pcie_data *data,
mutex_unlock(&data->yoyo.lock);
}
+static void
+btintel_pcie_yoyo_write_pairs(struct btintel_pcie_data *data,
+ struct btintel_pcie_yoyo_config_set *config_set,
+ resource_size_t bar0_len)
+{
+ u32 pair_addr, addr, value;
+ u32 i;
+
+ for (i = 0; i < config_set->num_pairs; i++) {
+ pair_addr = get_unaligned_le32(&config_set->pairs[i].address);
+
+ /* Calculate the effective address by adding the address offset */
+ if (check_add_overflow(pair_addr, config_set->addr_offset, &addr)) {
+ BT_WARN("YoYo: config set address overflow (0x%08x + 0x%08x)",
+ pair_addr, config_set->addr_offset);
+ continue;
+ }
+
+ value = get_unaligned_le32(&config_set->pairs[i].value);
+
+ switch (config_set->config_set_type) {
+ /* Direct Address Access (CSR) */
+ case BTINTEL_PCIE_CFGSET_CSR:
+ /* Validate the effective address for CSR access (Direct Address)
+ * addr not aligned to 4 bytes or exceeds the BAR0 length
+ */
+ if ((addr & (sizeof(u32) - 1)) ||
+ bar0_len < sizeof(u32) ||
+ addr > bar0_len - sizeof(u32)) {
+ BT_WARN("YoYo: bad CSR address 0x%08x for BAR0 length %llu",
+ addr, (unsigned long long)bar0_len);
+ continue;
+ }
+
+ BT_DBG("YoYo: CSR write [0x%08x] = 0x%08x", addr, value);
+ /* addr may be PRPH_DEV_* or HBUS_TARG_WRPTR */
+ spin_lock(&data->dev_mem_lock);
+ btintel_pcie_wr_reg32(data, addr, value);
+ spin_unlock(&data->dev_mem_lock);
+ break;
+ /* Indirect Address Access (Peripheral MAC and Device Memory) */
+ case BTINTEL_PCIE_CFGSET_PERIPH_MAC:
+ case BTINTEL_PCIE_CFGSET_DEVICE_MEM:
+ /* The config-set TLV comes from an untrusted external file;
+ * reject null or unaligned targets.
+ */
+ if (!addr || (addr & (sizeof(u32) - 1))) {
+ BT_WARN("YoYo: bad indirect address 0x%08x for type %u",
+ addr, config_set->config_set_type);
+ continue;
+ }
+
+ btintel_pcie_wr_dev_mem(data, addr, value);
+ BT_DBG("YoYo: indirect write type %u addr 0x%08x value 0x%08x",
+ config_set->config_set_type, addr, value);
+ break;
+ default:
+ BT_WARN("YoYo: unknown config_set type %u",
+ config_set->config_set_type);
+ break;
+ }
+ }
+}
+
static void
btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
u32 time_point)
@@ -1004,7 +1068,6 @@ btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
struct btintel_pcie_yoyo_config_set *config_set;
resource_size_t bar0_len;
int ret;
- u32 i;
if (!data)
return;
@@ -1016,98 +1079,34 @@ btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
return;
list_for_each_entry(config_set, &data->yoyo.config_set_list, list) {
- u32 pair_addr, addr, value;
-
if (config_set->time_point != time_point)
continue;
switch (config_set->config_set_type) {
case BTINTEL_PCIE_CFGSET_CSR:
+ btintel_pcie_yoyo_write_pairs(data, config_set, bar0_len);
+ break;
case BTINTEL_PCIE_CFGSET_PERIPH_MAC:
case BTINTEL_PCIE_CFGSET_DEVICE_MEM:
- break;
- default:
- BT_WARN("YoYo: unknown/unsupported config_set type %u, skipping",
- config_set->config_set_type);
- continue;
- }
-
- if (config_set->config_set_type == BTINTEL_PCIE_CFGSET_PERIPH_MAC ||
- config_set->config_set_type == BTINTEL_PCIE_CFGSET_DEVICE_MEM) {
mutex_lock(&data->mac_access_lock);
ret = btintel_pcie_get_mac_access(data);
- if (ret) {
+ if (ret)
BT_WARN("YoYo: MAC access failed for config set (%d), skipping",
ret);
- /* get_mac_access() asserts MAC_ACCESS_REQ before it
- * polls, and leaves it set on timeout; drop it so the
- * request bit is not leaked.
- */
- btintel_pcie_release_mac_access(data);
- mutex_unlock(&data->mac_access_lock);
- continue;
- }
- }
-
- for (i = 0; i < config_set->num_pairs; i++) {
- pair_addr = get_unaligned_le32(&config_set->pairs[i].address);
-
- /* Calculate the effective address by adding the address offset */
- if (check_add_overflow(pair_addr, config_set->addr_offset, &addr)) {
- BT_WARN("YoYo: config set address overflow (0x%08x + 0x%08x)",
- pair_addr, config_set->addr_offset);
- continue;
- }
-
- value = get_unaligned_le32(&config_set->pairs[i].value);
-
- switch (config_set->config_set_type) {
- /* Direct Address Access (CSR) */
- case BTINTEL_PCIE_CFGSET_CSR:
- /* Validate the effective address for CSR access (Direct Address)
- * addr not aligned to 4 bytes or exceeds the BAR0 length
- */
- if ((addr & (sizeof(u32) - 1)) ||
- bar0_len < sizeof(u32) ||
- addr > bar0_len - sizeof(u32)) {
- BT_WARN("YoYo: bad CSR address 0x%08x for BAR0 length %llu",
- addr, (unsigned long long)bar0_len);
- continue;
- }
-
- BT_DBG("YoYo: CSR write [0x%08x] = 0x%08x", addr, value);
- /* addr may be PRPH_DEV_* or HBUS_TARG_WRPTR */
- spin_lock(&data->dev_mem_lock);
- btintel_pcie_wr_reg32(data, addr, value);
- spin_unlock(&data->dev_mem_lock);
- break;
- /* Indirect Address Access (Peripheral MAC and Device Memory) */
- case BTINTEL_PCIE_CFGSET_PERIPH_MAC:
- case BTINTEL_PCIE_CFGSET_DEVICE_MEM:
- /* The config-set TLV comes from an untrusted external file;
- * reject null or unaligned targets.
- */
- if (!addr || (addr & (sizeof(u32) - 1))) {
- BT_WARN("YoYo: bad indirect address 0x%08x for type %u",
- addr, config_set->config_set_type);
- continue;
- }
-
- btintel_pcie_wr_dev_mem(data, addr, value);
- BT_DBG("YoYo: indirect write type %u addr 0x%08x value 0x%08x",
- config_set->config_set_type, addr, value);
- break;
- default:
- BT_WARN("YoYo: unknown config_set type %u",
- config_set->config_set_type);
- break;
- }
- }
-
- if (config_set->config_set_type == BTINTEL_PCIE_CFGSET_PERIPH_MAC ||
- config_set->config_set_type == BTINTEL_PCIE_CFGSET_DEVICE_MEM) {
+ else
+ btintel_pcie_yoyo_write_pairs(data, config_set,
+ bar0_len);
+ /* get_mac_access() asserts MAC_ACCESS_REQ before it
+ * polls, and leaves it set on timeout; drop it in both
+ * cases so the request bit is not leaked.
+ */
btintel_pcie_release_mac_access(data);
mutex_unlock(&data->mac_access_lock);
+ break;
+ default:
+ BT_WARN("YoYo: unknown/unsupported config_set type %u, skipping",
+ config_set->config_set_type);
+ break;
}
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: Bluetooth: btintel_pcie: fix context analysis error in YoYo config sets
2026-11-26 0:04 [PATCH] Bluetooth: btintel_pcie: fix context analysis error in YoYo config sets Rosen Penev
@ 2026-11-26 3:42 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-26 3:42 UTC (permalink / raw)
To: linux-bluetooth, rosenp
[-- Attachment #1: Type: text/plain, Size: 1562 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1222708/
---Test result---
Test Summary:
CheckPatch PASS 0.53 seconds
VerifyFixes PASS 0.05 seconds
VerifySignedoff PASS 0.05 seconds
GitLint FAIL 0.18 seconds
SubjectPrefix PASS 0.05 seconds
BuildKernel PASS 23.40 seconds
CheckAllWarning PASS 26.86 seconds
CheckSparse PASS 29.00 seconds
BuildKernel32 PASS 23.88 seconds
CheckKernelLLVM PASS 25.74 seconds
TestRunnerSetup PASS 552.92 seconds
IncrementalBuild PASS 22.06 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
Bluetooth: btintel_pcie: fix context analysis error in YoYo config sets
9: B1 Line exceeds max length (154>80): " drivers/bluetooth/btintel_pcie.c:1052:12: error: mutex 'data->mac_access_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]"
10: B1 Line exceeds max length (142>80): " drivers/bluetooth/btintel_pcie.c:1110:4: error: releasing mutex 'data->mac_access_lock' that was not held [-Werror,-Wthread-safety-analysis]"
https://github.com/bluez/bluetooth-next/pull/1232
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 3:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 0:04 [PATCH] Bluetooth: btintel_pcie: fix context analysis error in YoYo config sets Rosen Penev
2026-11-26 3:42 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox