net: dns: Close socket service properly from dispatcher

We need to close the socket service context when dispatcher is
unregistered.

Fixes #82652

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-12-09 14:57:06 +02:00 committed by Benjamin Cabé
commit da148ab3bc

View file

@ -334,6 +334,11 @@ int dns_dispatcher_unregister(struct dns_socket_dispatcher *ctx)
(void)sys_slist_find_and_remove(&sockets, &ctx->node);
(void)net_socket_service_unregister(ctx->svc);
/* Mark the context as unregistered */
ctx->sock = -1;
for (int i = 0; i < ctx->fds_len; i++) {
CHECKIF((int)ctx->fds[i].fd >= (int)ARRAY_SIZE(dispatch_table)) {
ret = -ERANGE;