]> 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)
committerOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2020 10:09:22 +0000 (11:09 +0100)
lib/dns/client.c

index 985b6f42c96867f41b90de21b985ec9dfaaa48be..34e65bd066c9f546c64bfd1c56823fcb4e4be8e9 100644 (file)
@@ -1340,13 +1340,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)
@@ -1748,13 +1742,7 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
                                   action, arg, sizeof(*event));
 
        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);
@@ -1787,16 +1775,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);