]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
h_GetHost_r cleanup cases
authorRuss Allbery <rra@stanford.edu>
Sat, 26 Sep 2009 00:50:54 +0000 (17:50 -0700)
committerDerrick Brashear <shadow|account-1000005@unknown>
Sat, 26 Sep 2009 09:16:34 +0000 (02:16 -0700)
avoid potentially leaking a cb_in or a capabilities blob;
use a common exit function and free when these were left set.

Reviewed-on: http://gerrit.openafs.org/496
Tested-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
(cherry picked from commit 5d765426e597c60228e66bddaa21bf2453c74a85)
Reviewed-on: http://gerrit.openafs.org/497
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/viced/host.c

index 1b6366b105e4695650ff51e5475fbe2ab5b14dd9..34cef0f52bb6b0ad96c2e5cb044156222fc5bc0a 100644 (file)
@@ -1447,7 +1447,8 @@ h_GetHost_r(struct rx_connection *tcon)
            h_threadquota(host->lock.num_waiting)) {
            if (!held)
                h_Release_r(host);
-           return 0;
+           host = NULL;
+           goto gethost_out;
        }
        h_Lock_r(host);
        if (!(host->hostFlags & ALTADDR)) {
@@ -1655,7 +1656,8 @@ h_GetHost_r(struct rx_connection *tcon)
                    h_Release_r(host);
                host = NULL;
                rx_DestroyConnection(cb_in);
-               return 0;
+               cb_in = NULL;
+               goto gethost_out;
            } else {
                ViceLog(0,
                        ("CB: WhoAreYou failed for host %x (%s:%d), error %d\n",
@@ -1936,10 +1938,16 @@ h_GetHost_r(struct rx_connection *tcon)
        host->hostFlags &= ~HWHO_INPROGRESS;
        h_Unlock_r(host);
     }
+
+ gethost_out:
     if (caps.Capabilities_val)
        free(caps.Capabilities_val);
     caps.Capabilities_val = NULL;
     caps.Capabilities_len = 0;
+    if (cb_in) {
+        rx_DestroyConnection(cb_in);
+        cb_in = NULL;
+    }
     return host;
 
 }                              /*h_GetHost_r */