diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-16 16:41:10 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-05-14 15:09:29 -0400 |
commit | 19445b99b6d66af661c586c052de23110731a502 (patch) | |
tree | b5a77b701b466598af631ef5a7db705f6e7c59ad /net/sunrpc | |
parent | ee5ebe851ed60206f150d3f189416f9c63245b66 (diff) |
SUNRPC: Cleanup - make rpc_new_task() call rpc_release_calldata on failure
Also have it return an ERR_PTR(-ENOMEM) instead of a null pointer.
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/clnt.c | 19 | ||||
-rw-r--r-- | net/sunrpc/sched.c | 13 |
2 files changed, 14 insertions, 18 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 19c9983d5360..8c7b5433022a 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -556,26 +556,16 @@ static const struct rpc_call_ops rpc_default_ops = { | |||
556 | */ | 556 | */ |
557 | struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data) | 557 | struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data) |
558 | { | 558 | { |
559 | struct rpc_task *task, *ret; | 559 | struct rpc_task *task; |
560 | 560 | ||
561 | task = rpc_new_task(task_setup_data); | 561 | task = rpc_new_task(task_setup_data); |
562 | if (task == NULL) { | 562 | if (IS_ERR(task)) |
563 | rpc_release_calldata(task_setup_data->callback_ops, | ||
564 | task_setup_data->callback_data); | ||
565 | ret = ERR_PTR(-ENOMEM); | ||
566 | goto out; | 563 | goto out; |
567 | } | ||
568 | 564 | ||
569 | if (task->tk_status != 0) { | ||
570 | ret = ERR_PTR(task->tk_status); | ||
571 | rpc_put_task(task); | ||
572 | goto out; | ||
573 | } | ||
574 | atomic_inc(&task->tk_count); | 565 | atomic_inc(&task->tk_count); |
575 | rpc_execute(task); | 566 | rpc_execute(task); |
576 | ret = task; | ||
577 | out: | 567 | out: |
578 | return ret; | 568 | return task; |
579 | } | 569 | } |
580 | EXPORT_SYMBOL_GPL(rpc_run_task); | 570 | EXPORT_SYMBOL_GPL(rpc_run_task); |
581 | 571 | ||
@@ -657,9 +647,8 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req, | |||
657 | * Create an rpc_task to send the data | 647 | * Create an rpc_task to send the data |
658 | */ | 648 | */ |
659 | task = rpc_new_task(&task_setup_data); | 649 | task = rpc_new_task(&task_setup_data); |
660 | if (!task) { | 650 | if (IS_ERR(task)) { |
661 | xprt_free_bc_request(req); | 651 | xprt_free_bc_request(req); |
662 | task = ERR_PTR(-ENOMEM); | ||
663 | goto out; | 652 | goto out; |
664 | } | 653 | } |
665 | task->tk_rqstp = req; | 654 | task->tk_rqstp = req; |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index aae6907fd546..c8979ce5d88a 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -856,16 +856,23 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data) | |||
856 | 856 | ||
857 | if (task == NULL) { | 857 | if (task == NULL) { |
858 | task = rpc_alloc_task(); | 858 | task = rpc_alloc_task(); |
859 | if (task == NULL) | 859 | if (task == NULL) { |
860 | goto out; | 860 | rpc_release_calldata(setup_data->callback_ops, |
861 | setup_data->callback_data); | ||
862 | return ERR_PTR(-ENOMEM); | ||
863 | } | ||
861 | flags = RPC_TASK_DYNAMIC; | 864 | flags = RPC_TASK_DYNAMIC; |
862 | } | 865 | } |
863 | 866 | ||
864 | rpc_init_task(task, setup_data); | 867 | rpc_init_task(task, setup_data); |
868 | if (task->tk_status < 0) { | ||
869 | int err = task->tk_status; | ||
870 | rpc_put_task(task); | ||
871 | return ERR_PTR(err); | ||
872 | } | ||
865 | 873 | ||
866 | task->tk_flags |= flags; | 874 | task->tk_flags |= flags; |
867 | dprintk("RPC: allocated task %p\n", task); | 875 | dprintk("RPC: allocated task %p\n", task); |
868 | out: | ||
869 | return task; | 876 | return task; |
870 | } | 877 | } |
871 | 878 | ||