From a546f1cd58abcdc129035cf4614c4b55f1e1b1f8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 3 Jun 2010 11:54:04 -0400 Subject: [PATCH] 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 Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/cm_cell.c | 10 ++++------ src/WINNT/afsd/cm_conn.c | 3 --- src/WINNT/afsd/cm_ioctl.c | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/WINNT/afsd/cm_cell.c b/src/WINNT/afsd/cm_cell.c index a54c0cbe48..317cd73b48 100644 --- a/src/WINNT/afsd/cm_cell.c +++ b/src/WINNT/afsd/cm_cell.c @@ -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); diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 6534904d48..33ac4c8bf4 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -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; } diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index 2b3bde0125..f7ffda8ddc 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -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;