nfs: fix some issues in nfs41_proc_reclaim_complete()
Subsystems (3)
PATCH 1/1 nfs: fix some issues in nfs41_proc_reclaim_complete()
The original code passed an ERR_PTR() to rpc_put_task() and instead of returning zero on success it returned -ENOMEM.
---
This was found by smatch and I've only compile tested it. Sorry. :/
fs/nfs/nfs4proc.c +4 -1
@@ -5218,9 +5218,12 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) msg.rpc_resp = &calldata->res; task_setup_data.callback_data = calldata; task =rpc_run_task (&task_setup_data); -if (IS_ERR (task)) +if (IS_ERR (task)) { status =PTR_ERR (task); + goto out; + }rpc_put_task (task); +return 0 ; out:dprintk ("<-- %s status=%d\n" , __func__, status);return status;
Quoted 15 lines · Dan Carpenter
The original code passed an
ERR_PTR()torpc_put_task()and instead of returning zero on success it returned-ENOMEM.Signed-off-by Dan Carpenter <[email protected]>---
This was found by smatch and I've only compile tested it. Sorry. :/fs/nfs/nfs4proc.c +0
-0@@ -5218,9 +5218,12 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) msg.rpc_resp = &calldata->res; task_setup_data.callback_data = calldata; task =rpc_run_task (&task_setup_data);
fs/nfs/nfs4proc.c static int nfs41_proc_reclaim_complete(struct nfs_client *clp) · line 5229
Quoted 10 lines
fs/nfs/nfs4proc.c +4
-1-if (IS_ERR (task)) +if (IS_ERR (task)) { status =PTR_ERR (task); + goto out; + }rpc_put_task (task); +return 0 ; out:dprintk ("<-- %s status=%d\n" , __func__, status);return status;
Dan, thanks for sending the fix.
For the sake of dprintk, how about doing this instead:
git diff --stat -p -M
fs/nfs/nfs4proc.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +8 -3
@@ -5204,12 +5204,14 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) .callback_ops = &nfs4_reclaim_complete_call_ops, .flags = RPC_TASK_ASYNC, }; -int status = -ENOMEM ; +int status;dprintk ("--> %s\n" , __func__); calldata =kzalloc (sizeof (*calldata),GFP_KERNEL ); -if (calldata =NULL ) +if (calldata =NULL ) { + status = -ENOMEM ; goto out; + } calldata->clp = clp; calldata->arg.one_fs =0 ; calldata->res.seq_res.sr_slotid =NFS4_MAX_SLOT_TABLE ;
@@ -5218,9 +5220,12 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) msg.rpc_resp = &calldata->res; task_setup_data.callback_data = calldata; task =rpc_run_task (&task_setup_data); -if (IS_ERR (task)) +if (IS_ERR (task)) { status =PTR_ERR (task); + goto out; + }rpc_put_task (task); + status =0 ; out:dprintk ("<-- %s status=%d\n" , __func__, status);return status;
Dan Carpenter
Acked-byQuoted 3 lines · Benny Halevy
Dan, thanks for sending the fix.
For the sake of dprintk, how about doing this instead:
Good point.
regards,
dan carpenter