From: Russ Allbery Date: Sat, 26 Sep 2009 07:50:54 +0000 (-0700) Subject: h_GetHost_r cleanup cases X-Git-Tag: debian/1.4.11+dfsg-3~2 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=0a8094daeda28cde10490ad016296609f4ff7cb0;p=packages%2Fo%2Fopenafs.git h_GetHost_r cleanup cases 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 Reviewed-by: Alistair Ferguson Reviewed-by: Jeffrey Altman (cherry picked from commit 5d765426e597c60228e66bddaa21bf2453c74a85) Reviewed-on: http://gerrit.openafs.org/497 Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/viced/host.c b/src/viced/host.c index b45b1d97b..6dbb4f4cb 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1449,7 +1449,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)) { @@ -1657,7 +1658,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", @@ -1938,10 +1940,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 */