net/tcp: fix tcp crash when net meet popen syscall

tcp_close_monitor should free all the connevents which
belong to current psock

Change-Id: Ifc625d7bc44a02930921d75975cb9b5835c2deeb
Signed-off-by: ligd <liguiding1@xiaomi.com>
(cherry picked from commit 7134b1df4aa91fe4f2575cd9c2322d36710865dc)
This commit is contained in:
ligd
2021-04-15 20:41:16 +08:00
committed by liguiding1
parent 1b2850b840
commit e3b05bbd14
+5 -7
View File
@@ -361,15 +361,13 @@ void tcp_close_monitor(FAR struct socket *psock)
/* Find and free the the connection event callback */
net_lock();
for (cb = conn->connevents;
cb != NULL && cb->priv != (FAR void *)psock;
cb = cb->nxtconn)
{
}
if (cb != NULL)
for (cb = conn->connevents; cb != NULL; cb = cb->nxtconn)
{
devif_conn_callback_free(conn->dev, cb, &conn->connevents);
if (cb->priv == (FAR void *)psock)
{
devif_conn_callback_free(conn->dev, cb, &conn->connevents);
}
}
/* Make sure that this socket is explicitly marked as closed */