Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Aneesh Kumar K.V and committed by
Eric Van Hensbergen
fe1cbaba 398c4f0e

+13 -9
+12 -8
net/9p/client.c
··· 304 304 c->tagpool = p9_idpool_create(); 305 305 if (IS_ERR(c->tagpool)) { 306 306 err = PTR_ERR(c->tagpool); 307 - c->tagpool = NULL; 308 307 goto error; 309 308 } 310 - 311 - p9_idpool_get(c->tagpool); /* reserve tag 0 */ 312 - 309 + err = p9_idpool_get(c->tagpool); /* reserve tag 0 */ 310 + if (err < 0) { 311 + p9_idpool_destroy(c->tagpool); 312 + goto error; 313 + } 313 314 c->max_tag = 0; 314 315 error: 315 316 return err; ··· 790 789 spin_lock_init(&clnt->lock); 791 790 INIT_LIST_HEAD(&clnt->fidlist); 792 791 793 - p9_tag_init(clnt); 792 + err = p9_tag_init(clnt); 793 + if (err < 0) 794 + goto free_client; 794 795 795 796 err = parse_opts(options, clnt); 796 797 if (err < 0) 797 - goto free_client; 798 + goto destroy_tagpool; 798 799 799 800 if (!clnt->trans_mod) 800 801 clnt->trans_mod = v9fs_get_default_trans(); ··· 805 802 err = -EPROTONOSUPPORT; 806 803 P9_DPRINTK(P9_DEBUG_ERROR, 807 804 "No transport defined or default transport\n"); 808 - goto free_client; 805 + goto destroy_tagpool; 809 806 } 810 807 811 808 clnt->fidpool = p9_idpool_create(); 812 809 if (IS_ERR(clnt->fidpool)) { 813 810 err = PTR_ERR(clnt->fidpool); 814 - clnt->fidpool = NULL; 815 811 goto put_trans; 816 812 } 817 813 ··· 836 834 p9_idpool_destroy(clnt->fidpool); 837 835 put_trans: 838 836 v9fs_put_trans(clnt->trans_mod); 837 + destroy_tagpool: 838 + p9_idpool_destroy(clnt->tagpool); 839 839 free_client: 840 840 kfree(clnt); 841 841 return ERR_PTR(err);
+1 -1
net/9p/util.c
··· 93 93 94 94 retry: 95 95 if (idr_pre_get(&p->pool, GFP_NOFS) == 0) 96 - return 0; 96 + return -1; 97 97 98 98 spin_lock_irqsave(&p->lock, flags); 99 99