From 4a311b9bb4788fe4f7820379956b4697eb819024 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 21 Oct 2022 08:08:37 +0000 Subject: [PATCH] Unlink the query under cleanup_query In the cleanup code of fctx_query() function there is a code path where 'query' is linked to 'fctx' and it is being destroyed. Make sure that 'query' is unlinked before destroying it. (cherry picked from commit ac889684c78bc54fc537a0d97b12ddd13c0b0267) --- lib/dns/resolver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 4f2e363b99..e136a74266 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2298,6 +2298,12 @@ cleanup_dispatch: } cleanup_query: + LOCK(&res->buckets[fctx->bucketnum].lock); + if (ISC_LINK_LINKED(query, link)) { + atomic_fetch_sub_release(&fctx->nqueries, 1); + ISC_LIST_UNLINK(fctx->queries, query, link); + } + UNLOCK(&res->buckets[fctx->bucketnum].lock); query->magic = 0; dns_message_detach(&query->rmessage);