From 82118acb6ed4f6fb90f3d864f4045d9c6bc2a55c Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Sun, 21 Jul 2019 17:58:48 -0500 Subject: [PATCH 1/1] afs: Introduce shutdown_dynroot() Add a shutdown sequence for dynroot, which frees the afs_dynrootDir and afs_dynrootMountDir blobs, if they exist. Otherwise, we can leak the memory allocated for those blobs. Change-Id: I80fe41a0fcacbd272677ff778cd4ba51399f32f9 Reviewed-on: https://gerrit.openafs.org/13713 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/afs/afs_call.c | 1 + src/afs/afs_dynroot.c | 23 +++++++++++++++++++++++ src/afs/afs_prototypes.h | 1 + 3 files changed, 25 insertions(+) diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index d2f9b07..44bdcbe 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -1520,6 +1520,7 @@ afs_shutdown(void) shutdown_nfsclnt(); #endif shutdown_afstest(); + shutdown_dynroot(); shutdown_AFS(); /* The following hold the cm stats */ memset(&afs_cmstats, 0, sizeof(struct afs_CMStats)); diff --git a/src/afs/afs_dynroot.c b/src/afs/afs_dynroot.c index a18602f..ab21f8a 100644 --- a/src/afs/afs_dynroot.c +++ b/src/afs/afs_dynroot.c @@ -916,3 +916,26 @@ afs_DynrootVOPSymlink(struct vcache *avc, afs_ucred_t *acred, afs_DynrootInvalidate(); return 0; } + +void +shutdown_dynroot(void) +{ + if (!afs_dynrootEnable) { + return; + } + + ObtainWriteLock(&afs_dynrootDirLock, 554); + + if (afs_dynrootDir) { + afs_osi_Free(afs_dynrootDir, afs_dynrootDirLen); + afs_dynrootDir = NULL; + afs_dynrootDirLen = 0; + } + if (afs_dynrootMountDir) { + afs_osi_Free(afs_dynrootMountDir, afs_dynrootMountDirLen); + afs_dynrootMountDir = NULL; + afs_dynrootMountDirLen = 0; + } + + ReleaseWriteLock(&afs_dynrootDirLock); +} diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index e2355e9..fe98f27 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -319,6 +319,7 @@ extern int afs_DynrootVOPRemove(struct vcache *avc, afs_ucred_t *acred, char *aname); extern int afs_DynrootVOPSymlink(struct vcache *avc, afs_ucred_t *acred, char *aname, char *atargetName); +extern void shutdown_dynroot(void); /* afs_error.c */ extern void init_et_to_sys_error(void); -- 1.9.4