Commit 8781ff94 authored by Eric Van Hensbergen's avatar Eric Van Hensbergen

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: default avatarVenkateswararao Jujjuri <jvrao@us.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent bf2d29c6
...@@ -676,18 +676,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -676,18 +676,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
clnt->trans = NULL; clnt->trans = NULL;
spin_lock_init(&clnt->lock); spin_lock_init(&clnt->lock);
INIT_LIST_HEAD(&clnt->fidlist); INIT_LIST_HEAD(&clnt->fidlist);
clnt->fidpool = p9_idpool_create();
if (IS_ERR(clnt->fidpool)) {
err = PTR_ERR(clnt->fidpool);
clnt->fidpool = NULL;
goto error;
}
p9_tag_init(clnt); p9_tag_init(clnt);
err = parse_opts(options, clnt); err = parse_opts(options, clnt);
if (err < 0) if (err < 0)
goto error; goto free_client;
if (!clnt->trans_mod) if (!clnt->trans_mod)
clnt->trans_mod = v9fs_get_default_trans(); clnt->trans_mod = v9fs_get_default_trans();
...@@ -696,7 +690,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -696,7 +690,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
"No transport defined or default transport\n"); "No transport defined or default transport\n");
goto error; goto free_client;
}
clnt->fidpool = p9_idpool_create();
if (IS_ERR(clnt->fidpool)) {
err = PTR_ERR(clnt->fidpool);
clnt->fidpool = NULL;
goto put_trans;
} }
P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", 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,19 +705,25 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
err = clnt->trans_mod->create(clnt, dev_name, options); err = clnt->trans_mod->create(clnt, dev_name, options);
if (err) if (err)
goto error; goto destroy_fidpool;
if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize)
clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ;
err = p9_client_version(clnt); err = p9_client_version(clnt);
if (err) if (err)
goto error; goto close_trans;
return clnt; return clnt;
error: close_trans:
p9_client_destroy(clnt); clnt->trans_mod->close(clnt);
destroy_fidpool:
p9_idpool_destroy(clnt->fidpool);
put_trans:
v9fs_put_trans(clnt->trans_mod);
free_client:
kfree(clnt);
return ERR_PTR(err); return ERR_PTR(err);
} }
EXPORT_SYMBOL(p9_client_create); EXPORT_SYMBOL(p9_client_create);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment