Print this page
Two NLM fixes: use zone_kcred() and plug cl_auth leaks

@@ -847,40 +847,48 @@
         /*
          * Create an RPC handle that'll be used for communication with local
          * statd using the status monitor protocol.
          */
         error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
-            0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
+            0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
         if (error != 0)
                 goto error;
 
         /*
          * Create an RPC handle that'll be used for communication with the
          * local statd using the address registration protocol.
          */
         error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
-            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
+            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
+            &nsm->ns_addr_handle);
         if (error != 0)
                 goto error;
 
         sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
         return (0);
 
 error:
         kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
-        if (nsm->ns_handle)
+        if (nsm->ns_handle) {
+                ASSERT(nsm->ns_handle->cl_auth != NULL);
+                auth_destroy(nsm->ns_handle->cl_auth);
                 CLNT_DESTROY(nsm->ns_handle);
+        }
 
         return (error);
 }
 
 static void
 nlm_nsm_fini(struct nlm_nsm *nsm)
 {
         kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
+        if (nsm->ns_addr_handle->cl_auth != NULL)
+                auth_destroy(nsm->ns_addr_handle->cl_auth);
         CLNT_DESTROY(nsm->ns_addr_handle);
         nsm->ns_addr_handle = NULL;
+        if (nsm->ns_handle->cl_auth != NULL)
+                auth_destroy(nsm->ns_handle->cl_auth);
         CLNT_DESTROY(nsm->ns_handle);
         nsm->ns_handle = NULL;
         sema_destroy(&nsm->ns_sem);
 }
 

@@ -2806,11 +2814,11 @@
 
 void
 nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
 {
         (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
-            NLM_RPC_RETRIES, kcred);
+            NLM_RPC_RETRIES, zone_kcred());
 }
 
 void
 nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
 {