diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-06-09 15:41:42 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-10 23:40:33 -0400 |
commit | 3ab9bb7243489f9db3abf3d05521ddfc6b184c0a (patch) | |
tree | 05476c58c87c5578354ab8a3befcb7316c9ef9bc /net/sunrpc/auth.c | |
parent | 03a1256f06cf1f58e33971fb4a524479e75c200e (diff) |
SUNRPC: Fix a memory leak in the auth credcache code
The leak only affects the RPCSEC_GSS caches, since they are the only ones
that are dynamically allocated...
Rename the existing rpcauth_free_credcache() to rpcauth_clear_credcache()
in order to better describe its role, then add a new function
rpcauth_destroy_credcache() that actually frees the cache in addition to
clearing it out.
Also move the call to destroy the credcache in gss_destroy() to come before
the rpc upcall pipe is unlinked.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r-- | net/sunrpc/auth.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 9527f2bb1744..f6b6c81cbc3e 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -137,9 +137,8 @@ void rpcauth_destroy_credlist(struct hlist_head *head) | |||
137 | * that are not referenced. | 137 | * that are not referenced. |
138 | */ | 138 | */ |
139 | void | 139 | void |
140 | rpcauth_free_credcache(struct rpc_auth *auth) | 140 | rpcauth_clear_credcache(struct rpc_cred_cache *cache) |
141 | { | 141 | { |
142 | struct rpc_cred_cache *cache = auth->au_credcache; | ||
143 | HLIST_HEAD(free); | 142 | HLIST_HEAD(free); |
144 | struct hlist_node *pos, *next; | 143 | struct hlist_node *pos, *next; |
145 | struct rpc_cred *cred; | 144 | struct rpc_cred *cred; |
@@ -157,6 +156,21 @@ rpcauth_free_credcache(struct rpc_auth *auth) | |||
157 | rpcauth_destroy_credlist(&free); | 156 | rpcauth_destroy_credlist(&free); |
158 | } | 157 | } |
159 | 158 | ||
159 | /* | ||
160 | * Destroy the RPC credential cache | ||
161 | */ | ||
162 | void | ||
163 | rpcauth_destroy_credcache(struct rpc_auth *auth) | ||
164 | { | ||
165 | struct rpc_cred_cache *cache = auth->au_credcache; | ||
166 | |||
167 | if (cache) { | ||
168 | auth->au_credcache = NULL; | ||
169 | rpcauth_clear_credcache(cache); | ||
170 | kfree(cache); | ||
171 | } | ||
172 | } | ||
173 | |||
160 | static void | 174 | static void |
161 | rpcauth_prune_expired(struct rpc_auth *auth, struct rpc_cred *cred, struct hlist_head *free) | 175 | rpcauth_prune_expired(struct rpc_auth *auth, struct rpc_cred *cred, struct hlist_head *free) |
162 | { | 176 | { |