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 03ba7c3ebab4b3071e2d69a2e6605cb5a08033a0
Author: Marco Casaroli <[email protected]>
AuthorDate: Sat Nov 21 17:06:51 2026 +0100

    net/tcp: Do not compute the receive window of a socket with no device.
    
    recv() on a TCP socket that never connected returns ENOTCONN.  After
    that, tcp_recvfrom_one() calls tcp_should_send_recvwindow().  The
    socket has no device (conn->dev is NULL).  When fewer than half of the
    I/O buffers are free, tcp_get_recvwindow() (at the throttle) or
    tcp_should_send_recvwindow() (above it) calls tcp_rx_mss() with the NULL
    device, and the kernel reads through a NULL pointer.
    
    Return false from tcp_should_send_recvwindow() when the connection has
    no device: there is no peer to send a window update to.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 net/tcp/tcp_recvwindow.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/tcp/tcp_recvwindow.c b/net/tcp/tcp_recvwindow.c
index e2f2dd2c5f7..aa6553f51ee 100644
--- a/net/tcp/tcp_recvwindow.c
+++ b/net/tcp/tcp_recvwindow.c
@@ -356,6 +356,13 @@ bool tcp_should_send_recvwindow(FAR struct tcp_conn_s 
*conn)
   uint32_t adv;
   uint16_t mss;
 
+  /* A socket that never connected has no device and no peer */
+
+  if (dev == NULL)
+    {
+      return false;
+    }
+
   /* Note: rcv_adv can be smaller than rcvseq.
    * For examples, when:
    *

Reply via email to