diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index 3a610d104eb..a431f312f3d 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -396,6 +396,8 @@ static uint16_t tcpsend_eventhandler(FAR struct net_driver_s *dev, else if ((flags & TCP_DISCONN_EVENTS) != 0) { + FAR struct socket *psock = pstate->snd_sock; + ninfo("Lost connection\n"); /* We could get here recursively through the callback actions of @@ -403,11 +405,12 @@ static uint16_t tcpsend_eventhandler(FAR struct net_driver_s *dev, * already been disconnected. */ + DEBUGASSERT(psock != NULL); if (_SS_ISCONNECTED(psock->s_flags)) { /* Report not connected */ - tcp_lost_connection(pstate->snd_sock, pstate->snd_cb, flags); + tcp_lost_connection(psock, pstate->snd_cb, flags); } pstate->snd_sent = -ENOTCONN;