summaryrefslogtreecommitdiff
path: root/net/sunrpc/sched.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2022-04-07 05:36:19 +0300
committerTrond Myklebust <trond.myklebust@hammerspace.com>2022-04-07 23:20:00 +0300
commit25cf32ad5dba79385f6e7de9008dcb75556c42d2 (patch)
treecb340ece410fea8667859d87484749fc26e82252 /net/sunrpc/sched.c
parent88dee0cc93adcd83db9d089c1163dc88edafd1c1 (diff)
downloadlinux-25cf32ad5dba79385f6e7de9008dcb75556c42d2.tar.xz
SUNRPC: Handle allocation failure in rpc_new_task()
If the call to rpc_alloc_task() fails, then ensure that the calldata is released, and that rpc_run_task() and rpc_run_bc_task() bail out early. Reported-by: NeilBrown <neilb@suse.de> Fixes: 910ad38697d9 ("NFS: Fix memory allocation in rpc_alloc_task()") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'net/sunrpc/sched.c')
-rw-r--r--net/sunrpc/sched.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index b258b87a3ec2..7f70c1e608b7 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -1128,6 +1128,11 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data)
if (task == NULL) {
task = rpc_alloc_task();
+ if (task == NULL) {
+ rpc_release_calldata(setup_data->callback_ops,
+ setup_data->callback_data);
+ return ERR_PTR(-ENOMEM);
+ }
flags = RPC_TASK_DYNAMIC;
}