Windows: Fix usage of cm_FreeServerList

cm_FreeServerList will set the input variable to NULL if the
contents of the list could in fact be freed.  If they could not
be freed, the individual entries are marked for deletion and will
not be subsequently used.  Do not set the list variable to NULL
after calling cm_FreeServerList otherwise memory can be leaked.

LICENSE MIT

Change-Id: Ia3cacd760d7395a2dd6b063643a8aa86f9e468b9
Reviewed-on: http://gerrit.openafs.org/2078
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2010-06-03 11:54:04 -04:00 committed by Jeffrey Altman
parent 64e08dca0b
commit a546f1cd58
3 changed files with 4 additions and 10 deletions

View File

@ -94,15 +94,13 @@ cm_cell_t *cm_UpdateCell(cm_cell_t * cp, afs_uint32 flags)
((cp->flags & CM_CELLFLAG_VLSERVER_INVALID)))
)
{
/* must empty cp->vlServersp */
if (cp->vlServersp) {
cm_FreeServerList(&cp->vlServersp, CM_FREESERVERLIST_DELETE);
cp->vlServersp = NULL;
}
lock_ReleaseMutex(&cp->mx);
mxheld = 0;
/* must empty cp->vlServersp */
if (cp->vlServersp)
cm_FreeServerList(&cp->vlServersp, CM_FREESERVERLIST_DELETE);
rock.cellp = cp;
rock.flags = flags;
code = cm_SearchCellRegistry(1, cp->name, NULL, cp->linkedName, cm_AddCellProc, &rock);

View File

@ -406,7 +406,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
lock_ReleaseWrite(&cm_serverLock);
if (free_svr_list) {
cm_FreeServerList(serverspp, 0);
serverspp = NULL;
serversp = NULL;
free_svr_list = 0;
}
@ -508,7 +507,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
if (free_svr_list) {
cm_FreeServerList(serverspp, 0);
serverspp = NULL;
serversp = NULL;
free_svr_list = 0;
}
@ -608,7 +606,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
/* Free the server list before cm_ForceUpdateVolume is called */
if (free_svr_list) {
cm_FreeServerList(serverspp, 0);
serverspp = NULL;
serversp = NULL;
free_svr_list = 0;
}

View File

@ -1486,7 +1486,6 @@ cm_IoctlNewCell(struct cm_ioctl *ioctlp, struct cm_user *userp)
/* delete all previous server lists - cm_FreeServerList will ask for write on cm_ServerLock*/
cm_FreeServerList(&cp->vlServersp, CM_FREESERVERLIST_DELETE);
cp->vlServersp = NULL;
lock_ReleaseWrite(&cm_cellLock);
rock.cellp = cp;