public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/15] NFSv41: Fix a memory leak in nfs41_proc_async_sequence()
@ 2010-06-14 21:51 Trond Myklebust
  2010-06-14 21:51 ` [PATCH 02/15] NFSv4.1: Clean up nfs4_setup_sequence Trond Myklebust
  0 siblings, 1 reply; 24+ messages in thread
From: Trond Myklebust @ 2010-06-14 21:51 UTC (permalink / raw)
  To: linux-nfs

If the call to rpc_call_async() fails, then the arguments will not be
freed, since there will be no call to nfs41_sequence_call_done

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/nfs4proc.c |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 70015dd..bb70ff7 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5078,18 +5078,27 @@ static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred)
 				       &res, args.sa_cache_this, 1);
 }
 
+struct nfs4_sequence_data {
+	struct nfs_client *clp;
+	struct nfs4_sequence_args args;
+	struct nfs4_sequence_res res;
+};
+
 static void nfs41_sequence_release(void *data)
 {
-	struct nfs_client *clp = (struct nfs_client *)data;
+	struct nfs4_sequence_data *calldata = data;
+	struct nfs_client *clp = calldata->clp;
 
 	if (atomic_read(&clp->cl_count) > 1)
 		nfs4_schedule_state_renewal(clp);
 	nfs_put_client(clp);
+	kfree(calldata);
 }
 
 static void nfs41_sequence_call_done(struct rpc_task *task, void *data)
 {
-	struct nfs_client *clp = (struct nfs_client *)data;
+	struct nfs4_sequence_data *calldata = data;
+	struct nfs_client *clp = calldata->clp;
 
 	nfs41_sequence_done(clp, task->tk_msg.rpc_resp, task->tk_status);
 
@@ -5106,19 +5115,16 @@ static void nfs41_sequence_call_done(struct rpc_task *task, void *data)
 	}
 	dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred);
 out:
-	kfree(task->tk_msg.rpc_argp);
-	kfree(task->tk_msg.rpc_resp);
-
 	dprintk("<-- %s\n", __func__);
 }
 
 static void nfs41_sequence_prepare(struct rpc_task *task, void *data)
 {
-	struct nfs_client *clp;
+	struct nfs4_sequence_data *calldata = data;
+	struct nfs_client *clp = calldata->clp;
 	struct nfs4_sequence_args *args;
 	struct nfs4_sequence_res *res;
 
-	clp = (struct nfs_client *)data;
 	args = task->tk_msg.rpc_argp;
 	res = task->tk_msg.rpc_resp;
 
@@ -5136,8 +5142,7 @@ static const struct rpc_call_ops nfs41_sequence_ops = {
 static int nfs41_proc_async_sequence(struct nfs_client *clp,
 				     struct rpc_cred *cred)
 {
-	struct nfs4_sequence_args *args;
-	struct nfs4_sequence_res *res;
+	struct nfs4_sequence_data *calldata;
 	struct rpc_message msg = {
 		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SEQUENCE],
 		.rpc_cred = cred,
@@ -5145,20 +5150,17 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp,
 
 	if (!atomic_inc_not_zero(&clp->cl_count))
 		return -EIO;
-	args = kzalloc(sizeof(*args), GFP_NOFS);
-	res = kzalloc(sizeof(*res), GFP_NOFS);
-	if (!args || !res) {
-		kfree(args);
-		kfree(res);
+	calldata = kmalloc(sizeof(*calldata), GFP_NOFS);
+	if (calldata == NULL) {
 		nfs_put_client(clp);
 		return -ENOMEM;
 	}
-	res->sr_slotid = NFS4_MAX_SLOT_TABLE;
-	msg.rpc_argp = args;
-	msg.rpc_resp = res;
+	msg.rpc_argp = &calldata->args;
+	msg.rpc_resp = &calldata->res;
+	calldata->clp = clp;
 
 	return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_SOFT,
-			      &nfs41_sequence_ops, (void *)clp);
+			      &nfs41_sequence_ops, calldata);
 }
 
 struct nfs4_reclaim_complete_data {
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2010-06-15 18:01 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-14 21:51 [PATCH 01/15] NFSv41: Fix a memory leak in nfs41_proc_async_sequence() Trond Myklebust
2010-06-14 21:51 ` [PATCH 02/15] NFSv4.1: Clean up nfs4_setup_sequence Trond Myklebust
2010-06-14 21:51   ` [PATCH 03/15] NFSv4.1: Simplify nfs41_sequence_done() Trond Myklebust
2010-06-14 21:51     ` [PATCH 04/15] NFSv4: Kill nfs4_async_handle_error() abuses by NFSv4.1 Trond Myklebust
2010-06-14 21:51       ` [PATCH 05/15] NFSv4.1: Merge the nfs41_proc_async_sequence() and nfs4_proc_sequence() Trond Myklebust
2010-06-14 21:51         ` [PATCH 06/15] NFSv4.1: Make nfs4_setup_sequence take a nfs_server argument Trond Myklebust
2010-06-14 21:51           ` [PATCH 07/15] NFSv41: Further cleanup for nfs4_sequence_done Trond Myklebust
2010-06-14 21:51             ` [PATCH 08/15] NFSv41: Don't store session state in the nfs_client->cl_state Trond Myklebust
2010-06-14 21:51               ` [PATCH 09/15] NFSv41: Clean up the NFSv4.1 minor version specific operations Trond Myklebust
2010-06-14 21:51                 ` [PATCH 10/15] NFSv41: Convert the various reboot recovery ops etc to minor version ops Trond Myklebust
2010-06-14 21:51                   ` [PATCH 11/15] NFSv41: Fix nfs_async_inode_return_delegation() ugliness Trond Myklebust
2010-06-14 21:51                     ` [PATCH 12/15] NFSv41: Deprecate nfs_client->cl_minorversion Trond Myklebust
2010-06-14 21:51                       ` [PATCH 13/15] NFSv41: Clean up exclusive create Trond Myklebust
2010-06-14 21:51                         ` [PATCH 14/15] NFSv41: Cleanup for nfs4_alloc_session Trond Myklebust
2010-06-14 21:51                           ` [PATCH 15/15] NFSv4.1: There is no need to init the session more than once Trond Myklebust
2010-06-14 23:13                         ` [PATCH 13/15] NFSv41: Clean up exclusive create Benny Halevy
2010-06-15 15:50                           ` Trond Myklebust
     [not found]                             ` <1276617009.8767.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-06-15 16:08                               ` Benny Halevy
2010-06-15 16:19                                 ` Trond Myklebust
     [not found]                                   ` <1276618750.8767.7.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-06-15 16:30                                     ` Benny Halevy
2010-06-15 16:50   ` [PATCH 02/15] NFSv4.1: Clean up nfs4_setup_sequence Gilliam, PaulX J
     [not found]     ` <0A97A441BFADC74EA1E299A79C69DF9213D49EB687-osO9UTpF0UQ64kNsxIetb7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-06-15 17:32       ` Trond Myklebust
2010-06-15 17:53         ` J. Bruce Fields
     [not found]         ` <1276623141.8767.47.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-06-15 18:01           ` Gilliam, PaulX J

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox