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 | |
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')
-rw-r--r-- | net/sunrpc/auth.c | 18 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 3 | ||||
-rw-r--r-- | net/sunrpc/auth_unix.c | 2 | ||||
-rw-r--r-- | net/sunrpc/sunrpc_syms.c | 2 |
4 files changed, 20 insertions, 5 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 | { |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 50809086fa1b..8b4c02f8befb 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -665,12 +665,13 @@ gss_destroy(struct rpc_auth *auth) | |||
665 | dprintk("RPC: destroying GSS authenticator %p flavor %d\n", | 665 | dprintk("RPC: destroying GSS authenticator %p flavor %d\n", |
666 | auth, auth->au_flavor); | 666 | auth, auth->au_flavor); |
667 | 667 | ||
668 | rpcauth_destroy_credcache(auth); | ||
669 | |||
668 | gss_auth = container_of(auth, struct gss_auth, rpc_auth); | 670 | gss_auth = container_of(auth, struct gss_auth, rpc_auth); |
669 | rpc_unlink(gss_auth->dentry); | 671 | rpc_unlink(gss_auth->dentry); |
670 | gss_auth->dentry = NULL; | 672 | gss_auth->dentry = NULL; |
671 | gss_mech_put(gss_auth->mech); | 673 | gss_mech_put(gss_auth->mech); |
672 | 674 | ||
673 | rpcauth_free_credcache(auth); | ||
674 | kfree(gss_auth); | 675 | kfree(gss_auth); |
675 | module_put(THIS_MODULE); | 676 | module_put(THIS_MODULE); |
676 | } | 677 | } |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 82300b83045e..5622783011a4 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -50,7 +50,7 @@ static void | |||
50 | unx_destroy(struct rpc_auth *auth) | 50 | unx_destroy(struct rpc_auth *auth) |
51 | { | 51 | { |
52 | dprintk("RPC: destroying UNIX authenticator %p\n", auth); | 52 | dprintk("RPC: destroying UNIX authenticator %p\n", auth); |
53 | rpcauth_free_credcache(auth); | 53 | rpcauth_clear_credcache(auth->au_credcache); |
54 | } | 54 | } |
55 | 55 | ||
56 | /* | 56 | /* |
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index b99b11b11461..3e19e7af6799 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c | |||
@@ -57,7 +57,7 @@ EXPORT_SYMBOL(rpcauth_unregister); | |||
57 | EXPORT_SYMBOL(rpcauth_create); | 57 | EXPORT_SYMBOL(rpcauth_create); |
58 | EXPORT_SYMBOL(rpcauth_lookupcred); | 58 | EXPORT_SYMBOL(rpcauth_lookupcred); |
59 | EXPORT_SYMBOL(rpcauth_lookup_credcache); | 59 | EXPORT_SYMBOL(rpcauth_lookup_credcache); |
60 | EXPORT_SYMBOL(rpcauth_free_credcache); | 60 | EXPORT_SYMBOL(rpcauth_destroy_credcache); |
61 | EXPORT_SYMBOL(rpcauth_init_credcache); | 61 | EXPORT_SYMBOL(rpcauth_init_credcache); |
62 | EXPORT_SYMBOL(put_rpccred); | 62 | EXPORT_SYMBOL(put_rpccred); |
63 | 63 | ||