net: sockets: tls: Fix net_context referencing
TLS sockets did not increase refcount of a net_context running TCP, which could lead to a crash upon TCP disconnection. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
6e25ebf269
commit
56566ad497
1 changed files with 5 additions and 0 deletions
|
@ -1174,6 +1174,10 @@ static int ztls_socket(int family, int type, int proto)
|
|||
ctx->tls->tls_version = tls_proto;
|
||||
}
|
||||
|
||||
if (proto == IPPROTO_TCP) {
|
||||
net_context_ref(ctx);
|
||||
}
|
||||
|
||||
z_finalize_fd(
|
||||
fd, ctx, (const struct fd_op_vtable *)&tls_sock_fd_op_vtable);
|
||||
|
||||
|
@ -1298,6 +1302,7 @@ int ztls_accept_ctx(struct net_context *parent, struct sockaddr *addr,
|
|||
}
|
||||
|
||||
net_context_set_accepting(child, false);
|
||||
net_context_ref(child);
|
||||
|
||||
z_finalize_fd(
|
||||
fd, child, (const struct fd_op_vtable *)&tls_sock_fd_op_vtable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue