From 33c3abb7062ff55e8448d4ff2acb3e82b7991585 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Wed, 13 Sep 2023 21:29:13 +0800 Subject: [PATCH] net/tcp: Stop monitor in `tcp_free` We may just free some TCP connections before monitor stopped, e.g. sacrificie a TCP conn in `tcp_alloc` will just call `tcp_free` and reuse the connection. But we noticed that the TCP monitor is not released in `tcp_free` because it is mounted on `conn->connevents` instead of `conn->sconn.list` while `tcp_free` only release the latter. Signed-off-by: Zhe Weng --- net/tcp/tcp_conn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 7bdeb5a357..3bc6fccddf 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -920,6 +920,10 @@ void tcp_free(FAR struct tcp_conn_s *conn) tcp_stop_timer(conn); + /* Make sure monitor is stopped. */ + + tcp_stop_monitor(conn, TCP_CLOSE); + /* Free remaining callbacks, actually there should be only the send * callback for CONFIG_NET_TCP_WRITE_BUFFERS is left. */