diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 82c019168d..f226d156bf 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1217,11 +1217,6 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { "search for response in bucket %d: %s", bucket, (resp == NULL ? "not found" : "found")); - if (resp == NULL) { - inc_stats(mgr, dns_resstatscounter_mismatch); - free_buffer(disp, ev->region.base, ev->region.length); - goto unlock; - } } else if (resp->id != id || !isc_sockaddr_equal(&ev->address, &resp->host)) { dispatch_log(disp, LVL(90), @@ -1231,6 +1226,12 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { goto unlock; } + if (resp == NULL) { + inc_stats(mgr, dns_resstatscounter_mismatch); + free_buffer(disp, ev->region.base, ev->region.length); + goto unlock; + } + /* * Now that we have the original dispatch the query was sent * from check that the address and port the response was