SUNRPC: Fix a memory leak in gss_create()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 9 Jun 2007 19:42:01 +0000 (15:42 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 11 Jul 2007 03:40:33 +0000 (23:40 -0400)
Fix a memory leak in gss_create() whereby the rpc credcache was not being
freed if the rpc_mkpipe() call failed.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/auth_gss/auth_gss.c

index 8b4c02f8befb5622d98f90bb0e763fa766c687c1..459dc9b1d1ad855b80591d7e298bc1f7d42b9afe 100644 (file)
@@ -636,10 +636,6 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
        auth->au_flavor = flavor;
        atomic_set(&auth->au_count, 1);
 
-       err = rpcauth_init_credcache(auth, GSS_CRED_EXPIRE);
-       if (err)
-               goto err_put_mech;
-
        gss_auth->dentry = rpc_mkpipe(clnt->cl_dentry, gss_auth->mech->gm_name,
                        clnt, &gss_upcall_ops, RPC_PIPE_WAIT_FOR_OPEN);
        if (IS_ERR(gss_auth->dentry)) {
@@ -647,7 +643,13 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
                goto err_put_mech;
        }
 
+       err = rpcauth_init_credcache(auth, GSS_CRED_EXPIRE);
+       if (err)
+               goto err_unlink_pipe;
+
        return auth;
+err_unlink_pipe:
+       rpc_unlink(gss_auth->dentry);
 err_put_mech:
        gss_mech_put(gss_auth->mech);
 err_free: