Skip to content

bt/ble_log: release fallback mutex on host write errors (IDFGH-17872)#18770

Open
Old-Ding wants to merge 1 commit into
espressif:masterfrom
Old-Ding:fix/ble-log-host-fallback-unlock
Open

bt/ble_log: release fallback mutex on host write errors (IDFGH-17872)#18770
Old-Ding wants to merge 1 commit into
espressif:masterfrom
Old-Ding:fix/ble-log-host-fallback-unlock

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This fixes the fallback path in ble_log_spi_out_host_write() so that LOG_MODULE_MUTEX(ul) is released on host write errors.

When no host task mapping is available, the function falls back to the ul log buffer and takes LOG_MODULE_MUTEX(ul). Two error paths after that point returned -1 directly, leaving the fallback mutex locked.

Changes

  • Use a single local exit path for ble_log_spi_out_host_write() after fallback lock ownership can exist.
  • Preserve the existing successful write behavior.
  • Keep the change limited to the deprecated BLE log SPI output implementation.

Testing

  • git diff --check origin/master..HEAD
  • rg -n "ble_log_spi_out_host_write|fallback|LOG_MODULE_MUTEX\\(ul\\)|return -1|goto exit|ret =" components/bt/common/ble_log/deprecated/ble_log_spi_out.c
  • git diff --stat origin/master..HEAD

Build not run locally: idf.py is not available in this Windows environment.


Note

Low Risk
Small, localized fix in deprecated BLE log SPI code; behavior on success is unchanged and only error cleanup is corrected.

Overview
Fixes a mutex leak in deprecated ble_log_spi_out_host_write() when the NimBLE fallback path is used (no host task mapping → takes LOG_MODULE_MUTEX(ul) and uses the ul log buffer).

Previously, oversized prefix and failed string formatting (total_len == 0) returned -1 immediately and never called xSemaphoreGive, which could deadlock other BLE log SPI output on ul.

The change routes those failures through a shared exit label, sets ret to 0 only on success, and always releases the fallback mutex before returning.

Reviewed by Cursor Bugbot for commit e349ca3. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

CLAassistant commented Jun 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 28, 2026
@github-actions github-actions Bot changed the title bt/ble_log: release fallback mutex on host write errors bt/ble_log: release fallback mutex on host write errors (IDFGH-17872) Jun 28, 2026
@Old-Ding Old-Ding force-pushed the fix/ble-log-host-fallback-unlock branch from 8250f96 to e349ca3 Compare June 29, 2026 01:02
@Old-Ding Old-Ding marked this pull request as ready for review June 29, 2026 01:03
@Old-Ding

Old-Ding commented Jul 7, 2026

Copy link
Copy Markdown
Author

Maintainer ping: CLA and the current checks are passing, the branch is mergeable, and this is still at Status: Opened. Could this be routed to the Bluetooth owner/reviewer for triage when possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants