From 9d4c708913e6b414e6620911c364fc22c4061ebb Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 5 Jun 2022 23:43:17 +0800 Subject: [PATCH] net/tcp: Search conn list again to aovid the race condition in tcp_timer_expiry Signed-off-by: Xiang Xiao --- net/tcp/tcp_timer.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 800023dfaa..b17a26a189 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -138,11 +138,20 @@ static int tcp_get_timeout(FAR struct tcp_conn_s *conn) static void tcp_timer_expiry(FAR void *arg) { - FAR struct tcp_conn_s *conn = arg; + FAR struct tcp_conn_s *conn = NULL; net_lock(); - conn->timeout = true; - netdev_txnotify_dev(conn->dev); + + while ((conn = tcp_nextconn(conn)) != NULL) + { + if (conn == arg) + { + conn->timeout = true; + netdev_txnotify_dev(conn->dev); + break; + } + } + net_unlock(); }