system/fastboot: fix socket() parameter order for TCP transport#3429
Open
JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
Open
system/fastboot: fix socket() parameter order for TCP transport#3429JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
Conversation
SOCK_CLOEXEC and SOCK_NONBLOCK were incorrectly passed as the third argument (protocol) instead of being OR'd into the second argument (type). This caused socket() to fail with EPROTONOSUPPORT (errno 93) on NuttX. Move SOCK_CLOEXEC | SOCK_NONBLOCK to the type parameter and set protocol to 0. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
xiaoxiang781216
approved these changes
Mar 20, 2026
Contributor
|
@JianyuWang0623 but we should follow/support Linux behavior? |
Contributor
Author
@xiaoxiang781216 Incorrect summary description (updated). The original code did not work properly on both NuttX and Linux. |
xiaoxiang781216
approved these changes
Mar 20, 2026
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.
Note: Please adhere to Contributing Guidelines.
Summary
In
fastboot_tcp_initialize(),SOCK_CLOEXECandSOCK_NONBLOCKwere passed as the third argument (protocol) ofsocket()instead of being OR'd into the second argument (type).The resulting protocol value (
SOCK_CLOEXEC | SOCK_NONBLOCK=0x80800) is not a valid protocol number, causingsocket()to fail on both Linux (EINVAL) and NuttX (EPROTONOSUPPORT). This means TCP transport has never worked.Fix: move
SOCK_CLOEXEC | SOCK_NONBLOCKinto thetypeparameter and setprotocolto 0.Impact
Without this fix,
fastbootdTCP transport fails on startup and cannot accept any connections. USB transport is not affected.No API or configuration changes. Existing defconfigs with
CONFIG_SYSTEM_FASTBOOT_TCP=ywill now work correctly without any modification.Testing
Build:
Runtime verification (before fix):
Runtime verification (after fix):