diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index b9cfa904b0a..1c5ce4eb433 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -325,6 +325,12 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, net_lock(); + if (conn->lport != 0) + { + net_unlock(); + return -EINVAL; + } + /* Verify or select a local port (network byte order) */ port = tcp_selectport(PF_INET, @@ -390,6 +396,12 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, net_lock(); + if (conn->lport != 0) + { + net_unlock(); + return -EINVAL; + } + /* Verify or select a local port (network byte order) */ /* The port number must be unique for this address binding */