aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-24 17:22:23 -0400
committerEric Van Hensbergen <ericvh@ericvh-desktop.austin.ibm.com>2008-09-24 17:22:23 -0400
commit571ffeafffbfdd0b8f2f9d3b991028797ec87e42 (patch)
treec48e86905efaa424fb87a9ed2878e6e3d90c9efc /net/9p
parent7dc5d24be06a5ed874af035d52a083a7b61ef1bd (diff)
9p-trans_fd: clean up p9_conn_create()
* Use kzalloc() to allocate p9_conn and remove 0/NULL initializations. * Clean up error return paths. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r--net/9p/trans_fd.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index ee0d151da31a..6c88e8983750 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -407,11 +407,11 @@ static void p9_mux_poll_stop(struct p9_conn *m)
407static struct p9_conn *p9_conn_create(struct p9_trans *trans) 407static struct p9_conn *p9_conn_create(struct p9_trans *trans)
408{ 408{
409 int i, n; 409 int i, n;
410 struct p9_conn *m, *mtmp; 410 struct p9_conn *m;
411 411
412 P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, 412 P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans,
413 trans->msize); 413 trans->msize);
414 m = kmalloc(sizeof(struct p9_conn), GFP_KERNEL); 414 m = kzalloc(sizeof(struct p9_conn), GFP_KERNEL);
415 if (!m) 415 if (!m)
416 return ERR_PTR(-ENOMEM); 416 return ERR_PTR(-ENOMEM);
417 417
@@ -422,24 +422,14 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans)
422 m->trans = trans; 422 m->trans = trans;
423 m->tagpool = p9_idpool_create(); 423 m->tagpool = p9_idpool_create();
424 if (IS_ERR(m->tagpool)) { 424 if (IS_ERR(m->tagpool)) {
425 mtmp = ERR_PTR(-ENOMEM);
426 kfree(m); 425 kfree(m);
427 return mtmp; 426 return ERR_PTR(-ENOMEM);
428 } 427 }
429 428
430 m->err = 0;
431 INIT_LIST_HEAD(&m->req_list); 429 INIT_LIST_HEAD(&m->req_list);
432 INIT_LIST_HEAD(&m->unsent_req_list); 430 INIT_LIST_HEAD(&m->unsent_req_list);
433 m->rcall = NULL;
434 m->rpos = 0;
435 m->rbuf = NULL;
436 m->wpos = m->wsize = 0;
437 m->wbuf = NULL;
438 INIT_WORK(&m->rq, p9_read_work); 431 INIT_WORK(&m->rq, p9_read_work);
439 INIT_WORK(&m->wq, p9_write_work); 432 INIT_WORK(&m->wq, p9_write_work);
440 m->wsched = 0;
441 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
442 m->poll_task = NULL;
443 n = p9_mux_poll_start(m); 433 n = p9_mux_poll_start(m);
444 if (n) { 434 if (n) {
445 kfree(m); 435 kfree(m);
@@ -460,10 +450,8 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans)
460 for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { 450 for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
461 if (IS_ERR(m->poll_waddr[i])) { 451 if (IS_ERR(m->poll_waddr[i])) {
462 p9_mux_poll_stop(m); 452 p9_mux_poll_stop(m);
463 mtmp = (void *)m->poll_waddr; /* the error code */
464 kfree(m); 453 kfree(m);
465 m = mtmp; 454 return (void *)m->poll_waddr; /* the error code */
466 break;
467 } 455 }
468 } 456 }
469 457