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 ac889684c7)
This commit is contained in:
Aram Sargsyan 2022-10-21 08:08:37 +00:00
parent b55f4068ff
commit 4a311b9bb4

View file

@ -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);