Skip to content

Commit

Permalink
9p: fix use after free
Browse files Browse the repository at this point in the history
On 7/22/07, Adrian Bunk <bunk@stusta.de> wrote:
     The Coverity checker spotted the following use-after-free
     in net/9p/mux.c:

     <--  snip  -->

     ...
     struct p9_conn *p9_conn_create(struct p9_transport *trans, int msize,
                                         unsigned char *extended)
     {
     ...
             if (!m->tagpool) {
                     kfree(m);
                     return ERR_PTR(PTR_ERR(m->tagpool));
             }
     ...

     <--  snip  -->

Also spotted was a leak of the same structure further down in the function.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Eric Van Hensbergen authored and Eric Van Hensbergen committed Aug 23, 2007
1 parent 8eb891f commit 1a3cac6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/9p/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ struct p9_conn *p9_conn_create(struct p9_transport *trans, int msize,
m->extended = extended;
m->trans = trans;
m->tagpool = p9_idpool_create();
if (!m->tagpool) {
if (IS_ERR(m->tagpool)) {
mtmp = ERR_PTR(-ENOMEM);
kfree(m);
return ERR_PTR(PTR_ERR(m->tagpool));
return mtmp;
}

m->err = 0;
Expand All @@ -308,8 +309,10 @@ struct p9_conn *p9_conn_create(struct p9_transport *trans, int msize,
memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
m->poll_task = NULL;
n = p9_mux_poll_start(m);
if (n)
if (n) {
kfree(m);
return ERR_PTR(n);
}

n = trans->poll(trans, &m->pt);
if (n & POLLIN) {
Expand Down

0 comments on commit 1a3cac6

Please sign in to comment.