net/context: Close TCP connection properly
Closing a connection, thus calling net_context_put() will not close a TCP connection properly, and will leak tcp connection memory. This is because: net_context_put calls net_context_unref which calls net_tcp_unref which leads to unref tcp connection and thus sets ctx->tcp to NULL. Back to net_context_put, that one finally calls net_tcp_put: but that bails out directly since ctx->tcp is NULL. Fixing it by inverting net_tcp_put() and net_context_unref() calls within net_context_put(). Fixes #38598 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
798588e709
commit
8a2e5b1648
@ -411,12 +411,12 @@ int net_context_put(struct net_context *context)
|
||||
context->recv_cb = NULL;
|
||||
context->send_cb = NULL;
|
||||
|
||||
/* Decrement refcount on user app's behalf */
|
||||
net_context_unref(context);
|
||||
|
||||
/* net_tcp_put() will handle decrementing refcount on stack's behalf */
|
||||
net_tcp_put(context);
|
||||
|
||||
/* Decrement refcount on user app's behalf */
|
||||
net_context_unref(context);
|
||||
|
||||
unlock:
|
||||
k_mutex_unlock(&context->lock);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user