aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/client.c
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@gmail.com>2010-02-08 19:18:34 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2010-02-08 19:18:34 -0500
commit8781ff9495578dbb74065fae55305110d9f81cb9 (patch)
tree01c42dc85934c729ee8d13e778ce991fad1f58e5 /net/9p/client.c
parentbf2d29c64dd777e9a40bc4533e721944a590250f (diff)
9p: fix p9_client_destroy unconditional calling v9fs_put_trans
restructure client create code to handle error cases better and only cleanup initialized portions of the stack. Signed-off-by: Venkateswararao Jujjuri <jvrao@us.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/client.c')
-rw-r--r--net/9p/client.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index cbe066966b3c..09d4f1e2e4a8 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -676,18 +676,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
676 clnt->trans = NULL; 676 clnt->trans = NULL;
677 spin_lock_init(&clnt->lock); 677 spin_lock_init(&clnt->lock);
678 INIT_LIST_HEAD(&clnt->fidlist); 678 INIT_LIST_HEAD(&clnt->fidlist);
679 clnt->fidpool = p9_idpool_create();
680 if (IS_ERR(clnt->fidpool)) {
681 err = PTR_ERR(clnt->fidpool);
682 clnt->fidpool = NULL;
683 goto error;
684 }
685 679
686 p9_tag_init(clnt); 680 p9_tag_init(clnt);
687 681
688 err = parse_opts(options, clnt); 682 err = parse_opts(options, clnt);
689 if (err < 0) 683 if (err < 0)
690 goto error; 684 goto free_client;
691 685
692 if (!clnt->trans_mod) 686 if (!clnt->trans_mod)
693 clnt->trans_mod = v9fs_get_default_trans(); 687 clnt->trans_mod = v9fs_get_default_trans();
@@ -696,7 +690,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
696 err = -EPROTONOSUPPORT; 690 err = -EPROTONOSUPPORT;
697 P9_DPRINTK(P9_DEBUG_ERROR, 691 P9_DPRINTK(P9_DEBUG_ERROR,
698 "No transport defined or default transport\n"); 692 "No transport defined or default transport\n");
699 goto error; 693 goto free_client;
694 }
695
696 clnt->fidpool = p9_idpool_create();
697 if (IS_ERR(clnt->fidpool)) {
698 err = PTR_ERR(clnt->fidpool);
699 clnt->fidpool = NULL;
700 goto put_trans;
700 } 701 }
701 702
702 P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", 703 P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n",
@@ -704,19 +705,25 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
704 705
705 err = clnt->trans_mod->create(clnt, dev_name, options); 706 err = clnt->trans_mod->create(clnt, dev_name, options);
706 if (err) 707 if (err)
707 goto error; 708 goto destroy_fidpool;
708 709
709 if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) 710 if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize)
710 clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; 711 clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ;
711 712
712 err = p9_client_version(clnt); 713 err = p9_client_version(clnt);
713 if (err) 714 if (err)
714 goto error; 715 goto close_trans;
715 716
716 return clnt; 717 return clnt;
717 718
718error: 719close_trans:
719 p9_client_destroy(clnt); 720 clnt->trans_mod->close(clnt);
721destroy_fidpool:
722 p9_idpool_destroy(clnt->fidpool);
723put_trans:
724 v9fs_put_trans(clnt->trans_mod);
725free_client:
726 kfree(clnt);
720 return ERR_PTR(err); 727 return ERR_PTR(err);
721} 728}
722EXPORT_SYMBOL(p9_client_create); 729EXPORT_SYMBOL(p9_client_create);