This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit be0272fd39f9af981618bed9c64360f8da095544 Author: yangjianqing <[email protected]> AuthorDate: Mon Mar 9 19:53:16 2026 +0800 net/tcp: fix potential null pointer dereference in tcp_input Cache conn->blparent->sconn into a local variable to prevent dereferencing a potentially NULL blparent. blparent may be set to NULL in accept progress Signed-off-by: yangjianqing <[email protected]> --- net/tcp/tcp_input.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 322ed9c9dae..6a3284f670c 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -1082,23 +1082,26 @@ found: } else { - nwarn("WARNING: RESET TCP state: TCP_CLOSED\n"); #ifdef CONFIG_NET_TCPBACKLOG /* Race condition: * case1) blparent is in close progress * case2) conn is in accept progress */ + FAR struct tcp_conn_s *listen; + tcp_conn_list_lock(); - if (conn->blparent != NULL) + listen = conn->blparent; + if (listen != NULL) { bool orphaned = false; + /* If this connection is, itself, backlogged, * then remove it from the parent connection's * backlog list. */ - conn_lock(&conn->blparent->sconn); + conn_lock(&listen->sconn); /* Double check the connection is in accept progress */ @@ -1108,7 +1111,7 @@ found: orphaned = true; } - conn_unlock(&conn->blparent->sconn); + conn_unlock(&listen->sconn); if (orphaned) { @@ -1124,6 +1127,7 @@ found: tcp_conn_list_unlock(); #endif + nwarn("WARNING: RESET TCP state: TCP_CLOSED\n"); conn->tcpstateflags = TCP_CLOSED; /* Notify this connection of the reset event */
