]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
isc_mem_get cannot fail
authorMark Andrews <marka@isc.org>
Thu, 30 Jan 2020 08:41:32 +0000 (19:41 +1100)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 5 Feb 2020 08:08:35 +0000 (09:08 +0100)
(cherry picked from commit bb65e5729725930769e3ee420fec655efe37440c)

lib/dns/client.c

index 85731df56e9d382ab3584a0b744094e317cdb8b2..945a7628a3ae03b9f3135c7036f926bb5ff0fe64 100644 (file)
@@ -1386,13 +1386,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
        ISC_LIST_INIT(event->answerlist);
 
        rctx = isc_mem_get(mctx, sizeof(*rctx));
-       if (rctx == NULL)
-               result = ISC_R_NOMEMORY;
-       else {
-               isc_mutex_init(&rctx->lock);
-       }
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_mutex_init(&rctx->lock);
 
        result = getrdataset(mctx, &rdataset);
        if (result != ISC_R_SUCCESS)
@@ -1775,13 +1769,7 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
        }
 
        ctx = isc_mem_get(client->mctx, sizeof(*ctx));
-       if (ctx == NULL)
-               result = ISC_R_NOMEMORY;
-       else {
-               isc_mutex_init(&ctx->lock);
-       }
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_mutex_init(&ctx->lock);
 
        ctx->client = client;
        ISC_LINK_INIT(ctx, link);
@@ -1814,16 +1802,13 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
 
        isc_refcount_decrement(&client->references);
 
- cleanup:
-       if (ctx != NULL) {
-               LOCK(&client->lock);
-               ISC_LIST_UNLINK(client->reqctxs, ctx, link);
-               UNLOCK(&client->lock);
-               isc_mutex_destroy(&ctx->lock);
-               isc_mem_put(client->mctx, ctx, sizeof(*ctx));
-       }
-       if (event != NULL)
-               isc_event_free(ISC_EVENT_PTR(&event));
+       LOCK(&client->lock);
+       ISC_LIST_UNLINK(client->reqctxs, ctx, link);
+       UNLOCK(&client->lock);
+       isc_mutex_destroy(&ctx->lock);
+       isc_mem_put(client->mctx, ctx, sizeof(*ctx));
+
+       isc_event_free(ISC_EVENT_PTR(&event));
        isc_task_detach(&tclone);
        dns_view_detach(&view);