RPC: struct rpc_auth initialization and destruction code cleanup Move the initialization of auth->au_count into the flavour-specific code. Move the kfree(auth) into the flavour-specific code. Signed-off-by: Trond Myklebust --- auth.c | 2 -- auth_gss/auth_gss.c | 2 ++ auth_null.c | 2 ++ auth_unix.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) Index: linux-2.6.11-rc3/net/sunrpc/auth.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth.c +++ linux-2.6.11-rc3/net/sunrpc/auth.c @@ -70,7 +70,6 @@ rpcauth_create(rpc_authflavor_t pseudofl auth = ops->create(clnt, pseudoflavor); if (!auth) return NULL; - atomic_set(&auth->au_count, 1); if (clnt->cl_auth) rpcauth_destroy(clnt->cl_auth); clnt->cl_auth = auth; @@ -83,7 +82,6 @@ rpcauth_destroy(struct rpc_auth *auth) if (!atomic_dec_and_test(&auth->au_count)) return; auth->au_ops->destroy(auth); - kfree(auth); } static DEFINE_SPINLOCK(rpc_credcache_lock); Index: linux-2.6.11-rc3/net/sunrpc/auth_null.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_null.c +++ linux-2.6.11-rc3/net/sunrpc/auth_null.c @@ -32,6 +32,7 @@ nul_create(struct rpc_clnt *clnt, rpc_au auth->au_rslack = 2; auth->au_ops = &authnull_ops; auth->au_expire = 1800 * HZ; + atomic_set(&auth->au_count, 1); rpcauth_init_credcache(auth); return (struct rpc_auth *) auth; @@ -42,6 +43,7 @@ nul_destroy(struct rpc_auth *auth) { dprintk("RPC: destroying NULL authenticator %p\n", auth); rpcauth_free_credcache(auth); + kfree(auth); } /* Index: linux-2.6.11-rc3/net/sunrpc/auth_unix.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_unix.c +++ linux-2.6.11-rc3/net/sunrpc/auth_unix.c @@ -50,6 +50,7 @@ unx_create(struct rpc_clnt *clnt, rpc_au auth->au_rslack = 2; /* assume AUTH_NULL verf */ auth->au_expire = UNX_CRED_EXPIRE; auth->au_ops = &authunix_ops; + atomic_set(&auth->au_count, 1); rpcauth_init_credcache(auth); @@ -61,6 +62,7 @@ unx_destroy(struct rpc_auth *auth) { dprintk("RPC: destroying UNIX authenticator %p\n", auth); rpcauth_free_credcache(auth); + kfree(auth); } static struct rpc_cred * Index: linux-2.6.11-rc3/net/sunrpc/auth_gss/auth_gss.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_gss/auth_gss.c +++ linux-2.6.11-rc3/net/sunrpc/auth_gss/auth_gss.c @@ -584,6 +584,7 @@ gss_create(struct rpc_clnt *clnt, rpc_au auth->au_expire = GSS_CRED_EXPIRE; auth->au_ops = &authgss_ops; auth->au_flavor = flavor; + atomic_set(&auth->au_count, 1); rpcauth_init_credcache(auth); @@ -617,6 +618,7 @@ gss_destroy(struct rpc_auth *auth) gss_mech_put(gss_auth->mech); rpcauth_free_credcache(auth); + kfree(gss_auth); module_put(THIS_MODULE); }