mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-10-04 16:49:17 +00:00
net/9p: p9_idpool_get return -1 on error
We need to return -1 on error. Also handle error properly Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
This commit is contained in:
parent
398c4f0efb
commit
fe1cbabaea
@ -304,12 +304,13 @@ static int p9_tag_init(struct p9_client *c)
|
|||||||
c->tagpool = p9_idpool_create();
|
c->tagpool = p9_idpool_create();
|
||||||
if (IS_ERR(c->tagpool)) {
|
if (IS_ERR(c->tagpool)) {
|
||||||
err = PTR_ERR(c->tagpool);
|
err = PTR_ERR(c->tagpool);
|
||||||
c->tagpool = NULL;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
err = p9_idpool_get(c->tagpool); /* reserve tag 0 */
|
||||||
p9_idpool_get(c->tagpool); /* reserve tag 0 */
|
if (err < 0) {
|
||||||
|
p9_idpool_destroy(c->tagpool);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
c->max_tag = 0;
|
c->max_tag = 0;
|
||||||
error:
|
error:
|
||||||
return err;
|
return err;
|
||||||
@ -789,11 +790,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
|
|||||||
spin_lock_init(&clnt->lock);
|
spin_lock_init(&clnt->lock);
|
||||||
INIT_LIST_HEAD(&clnt->fidlist);
|
INIT_LIST_HEAD(&clnt->fidlist);
|
||||||
|
|
||||||
p9_tag_init(clnt);
|
err = p9_tag_init(clnt);
|
||||||
|
if (err < 0)
|
||||||
|
goto free_client;
|
||||||
|
|
||||||
err = parse_opts(options, clnt);
|
err = parse_opts(options, clnt);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto free_client;
|
goto destroy_tagpool;
|
||||||
|
|
||||||
if (!clnt->trans_mod)
|
if (!clnt->trans_mod)
|
||||||
clnt->trans_mod = v9fs_get_default_trans();
|
clnt->trans_mod = v9fs_get_default_trans();
|
||||||
@ -802,13 +805,12 @@ 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 free_client;
|
goto destroy_tagpool;
|
||||||
}
|
}
|
||||||
|
|
||||||
clnt->fidpool = p9_idpool_create();
|
clnt->fidpool = p9_idpool_create();
|
||||||
if (IS_ERR(clnt->fidpool)) {
|
if (IS_ERR(clnt->fidpool)) {
|
||||||
err = PTR_ERR(clnt->fidpool);
|
err = PTR_ERR(clnt->fidpool);
|
||||||
clnt->fidpool = NULL;
|
|
||||||
goto put_trans;
|
goto put_trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -834,6 +836,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
|
|||||||
p9_idpool_destroy(clnt->fidpool);
|
p9_idpool_destroy(clnt->fidpool);
|
||||||
put_trans:
|
put_trans:
|
||||||
v9fs_put_trans(clnt->trans_mod);
|
v9fs_put_trans(clnt->trans_mod);
|
||||||
|
destroy_tagpool:
|
||||||
|
p9_idpool_destroy(clnt->tagpool);
|
||||||
free_client:
|
free_client:
|
||||||
kfree(clnt);
|
kfree(clnt);
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
|
@ -93,7 +93,7 @@ int p9_idpool_get(struct p9_idpool *p)
|
|||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (idr_pre_get(&p->pool, GFP_NOFS) == 0)
|
if (idr_pre_get(&p->pool, GFP_NOFS) == 0)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
spin_lock_irqsave(&p->lock, flags);
|
spin_lock_irqsave(&p->lock, flags);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user