-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Bluetooth: TBS: Fix TBS API accessing NULL inst #90613
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue in the TBS API where a mutex was accessed on a NULL instance, and it standardizes the control flow for error checking across several TBS functions. Key changes include:
- Reordering the NULL-check to occur before taking the mutex.
- Replacing the local variable “status” with “ret” for storing return values.
- Standardizing function structure and logging messages across the API.
566b050
to
98d9ad1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures TBS API functions check for a NULL instance before taking the mutex and unifies the variable names/structure across those functions.
- Reordered NULL checks ahead of
k_mutex_lock
in all TBS API calls - Replaced
status
withret
and made struct initializers use a consistent braced layout - Added
LOG_DBG
messages for lookup failures
Comments suppressed due to low confidence (2)
subsys/bluetooth/audio/tbs.c:2525
- In
bt_tbs_join
, the count passed tojoin_calls
should be clamped toCONFIG_BT_TBS_MAX_CALLS
(e.g.,MIN(call_index_cnt, CONFIG_BT_TBS_MAX_CALLS)
) to match the earliermemcpy
and avoid out-of-bounds processing.
ret = join_calls(inst, ccp, call_index_cnt);
subsys/bluetooth/audio/tbs.c:2502
- [nitpick] For consistency with the rest of the TBS API, consider returning a TBS-specific result code (e.g.,
BT_TBS_RESULT_CODE_INVALID_CALL_INDEX
or a dedicated invalid-parameter code) instead of a raw-EINVAL
.
return -EINVAL;
98d9ad1
to
89765bf
Compare
89765bf
to
2b262ba
Compare
Some TBS API functions attempted to take the mutex of an instance before the NULL check. Reorder the checks of the functions, and also modify function to be more similar (using the same terms and structure). Signed-off-by: Emil Gydesen <[email protected]>
2b262ba
to
7f651cf
Compare
|
Some TBS API functions attempted to take the mutex of an instance before the NULL check.
Reorder the checks of the functions, and also modify function to be more similar (using the same terms and structure).
fixes #90552
fixes #90527