diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-11-21 10:40:23 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-06 10:46:28 -0500 |
commit | 23bf85ba43650e4341672a6bc85aa3f2c02eb633 (patch) | |
tree | 0c88e0bda09955d749bd27bfa115e1cdd4f9efc4 /net/sunrpc/clnt.c | |
parent | e8e058e830f46a76f837522e5e2df46d4303111f (diff) | |
download | lwn-23bf85ba43650e4341672a6bc85aa3f2c02eb633.tar.gz lwn-23bf85ba43650e4341672a6bc85aa3f2c02eb633.zip |
SUNRPC: Handle the cases where rpc_alloc_iostats() fails
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r-- | net/sunrpc/clnt.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index a323abc7ea85..de8bbfcd5030 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -141,6 +141,9 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s clnt->cl_vers = version->number; clnt->cl_stats = program->stats; clnt->cl_metrics = rpc_alloc_iostats(clnt); + err = -ENOMEM; + if (clnt->cl_metrics == NULL) + goto out_no_stats; if (!xprt_bound(clnt->cl_xprt)) clnt->cl_autobind = 1; @@ -173,6 +176,8 @@ out_no_auth: rpc_put_mount(); } out_no_path: + rpc_free_iostats(clnt->cl_metrics); +out_no_stats: if (clnt->cl_server != clnt->cl_inline_name) kfree(clnt->cl_server); kfree(clnt); @@ -258,6 +263,9 @@ rpc_clone_client(struct rpc_clnt *clnt) goto out_no_clnt; atomic_set(&new->cl_count, 1); atomic_set(&new->cl_users, 0); + new->cl_metrics = rpc_alloc_iostats(clnt); + if (new->cl_metrics == NULL) + goto out_no_stats; new->cl_parent = clnt; atomic_inc(&clnt->cl_count); new->cl_xprt = xprt_get(clnt->cl_xprt); @@ -270,8 +278,9 @@ rpc_clone_client(struct rpc_clnt *clnt) rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval); if (new->cl_auth) atomic_inc(&new->cl_auth->au_count); - new->cl_metrics = rpc_alloc_iostats(clnt); return new; +out_no_stats: + kfree(new); out_no_clnt: printk(KERN_INFO "RPC: out of memory in %s\n", __FUNCTION__); return ERR_PTR(-ENOMEM); |