net: tcp: Fix possible deadlock in tcp_conn_unref()
Unlock tcp_lock when calling the recv_cb. In case when a connection is being closed from both the tcp stack and the application, a race condition can happen resulting in locking each other out on tcp_lock and socket lock. Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
This commit is contained in:
parent
9397dafa95
commit
e7489d8de7
1 changed files with 2 additions and 0 deletions
|
@ -403,8 +403,10 @@ static int tcp_conn_unref(struct tcp *conn)
|
|||
}
|
||||
|
||||
if (conn->context->recv_cb) {
|
||||
k_mutex_unlock(&tcp_lock);
|
||||
conn->context->recv_cb(conn->context, NULL, NULL, NULL,
|
||||
-ECONNRESET, conn->recv_user_data);
|
||||
k_mutex_lock(&tcp_lock, K_FOREVER);
|
||||
}
|
||||
|
||||
conn->context->tcp = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue