Bluetooth: att: fix retry check swallowing non-security ATT errors - #57
Open
nktn wants to merge 1 commit into
Open
Bluetooth: att: fix retry check swallowing non-security ATT errors#57nktn wants to merge 1 commit into
nktn wants to merge 1 commit into
Conversation
Commit 339570e ("bluetooth: att: Properly retry on errors mid-encryption.") changed the CONFIG_BT_ATT_RETRY_ON_SEC_ERR check to also retry while a security upgrade is in progress, but stored att_change_security()'s int return value in a uint8_t. As a result set_sec_err >= 0 is always true and == -EBUSY can never match: every ATT error response on a pending request (e.g. 0x0a Attribute Not Found at the end of a GATT discovery) cancels the ATT timeout, marks the request as retrying and never reaches att_handle_rsp(), so GATT client requests hang forever whenever the server returns an error that security elevation cannot fix. Use int and check == 0 || == -EBUSY, matching upstream Zephyr v3.6.0+ (att_error_rsp() in subsys/bluetooth/host/att.c). Signed-off-by: Fumihiko Nakatani <cube35@live.jp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes an incorrect return-value type in 339570e ("bluetooth: att: Properly
retry on errors mid-encryption.") on the
v3.5.0+zmk-fixesbranch.That commit addresses a real race — an ATT error can arrive while a
security upgrade is already in progress, and the request should still be
retried in that case. Upstream Zephyr later made the same improvement in
v3.6.0, so the intent matches where upstream ended up as well.
The implementation stores
att_change_security()'sintreturn value(which can be
-EINVAL,-EALREADY,-EBUSY, or an error frombt_conn_set_security()) in auint8_t:Since a
uint8_tis never negative,set_sec_err >= 0is always true,so every ATT error response handled by this path is treated as retryable.
the ATT timeout is cancelled, the request is marked
retrying, andatt_handle_rsp()is never called. For errors that security elevationcannot fix — e.g.
0x0aAttribute Not Found at the end of a GATTdiscovery — no security-change event will ever arrive, so the request
hangs forever and the GATT callback never fires.
For comparison: v3.6.0+ has the same mid-encryption improvement but
keeps the return value in an
int(ret == 0 || ret == -EBUSY), whilevanilla v3.5.0 retries only on
0. Neither exhibits the hang — onlythis branch's
uint8_tvariant does.Fix
Use
intand check== 0 || == -EBUSY, matching upstream v3.6.0+(
att_error_rsp()insubsys/bluetooth/host/att.c). This keeps themid-encryption retry behavior the original commit introduced, while
letting non-recoverable errors reach
att_handle_rsp()again.Two-line change; no behavioral difference for the genuine
security-retry cases (
0/-EBUSY).