Skip to content

Bluetooth: BAP: SD: Add missing error checks for mutex locks #90616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented May 26, 2025

Add missing error checks for mutex locks after the mutexes were changed to not use K_FOREVER which should not be done in the BT RX thread.

A larger overhaul of how mutexes are using within the scan delegator should be considered, as there are a lot of locks and unlocks when handling the callbacks.

fixes #90485
fixes #90475

@Thalley Thalley requested a review from Copilot May 26, 2025 15:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds error handling for mutex lock operations in the scan delegator after replacing blocking locks with timed locks.

  • Replaces k_mutex_lock(..., K_FOREVER) with timed locks using SCAN_DELEGATOR_BUF_SEM_TIMEOUT and checks for failures.
  • Logs failures and returns an error when mutex locking times out in scan_delegator_add_src and scan_delegator_mod_src.
Comments suppressed due to low confidence (1)

subsys/bluetooth/audio/bap_scan_delegator.c:767

  • [nitpick] Add or extend unit tests to simulate mutex timeouts and verify that BT_ATT_ERR_INSUFFICIENT_RESOURCES is returned correctly on lock failure.
err = k_mutex_lock(&internal_state->mutex, SCAN_DELEGATOR_BUF_SEM_TIMEOUT);

Add missing error checks for mutex locks after the mutexes
were changed to not use K_FOREVER which should not be done in
the BT RX thread.

A larger overhaul of how mutexes are using within the scan delegator
should be considered, as there are a lot of locks and unlocks when
handling the callbacks.

Signed-off-by: Emil Gydesen <[email protected]>
@Thalley Thalley force-pushed the bap_scan_del_fix_mutex_lock branch from 069366e to 30e5438 Compare July 1, 2025 12:23
Copy link

sonarqubecloud bot commented Jul 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Review
1 participant