Skip to content

Commit

Permalink
9P/RDMA: Do not free req->rc in error handling in rdma_request()
Browse files Browse the repository at this point in the history
rdma_request() should never be in charge of freeing rc.

When an error occurs:
* Either the rc buffer has been recv_post()'ed.
  then kfree()'ing it certainly is a bad idea.
* Or is has not, and in that case req->rc still points to it,
  hence it needs not be freed.

Signed-off-by: Simon Derr <simon.derr@bull.net>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Simon Derr authored and Eric Van Hensbergen committed Jul 8, 2013
1 parent fd453d0 commit b530e25
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions net/9p/trans_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
err = post_recv(client, rpl_context);
if (err) {
p9_debug(P9_DEBUG_FCALL, "POST RECV failed\n");
goto err_free1;
goto err_free;
}

/* remove posted receive buffer from request structure */
Expand All @@ -457,7 +457,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
c = kmalloc(sizeof *c, GFP_NOFS);
if (!c) {
err = -ENOMEM;
goto err_free1;
goto err_free;
}
c->req = req;

Expand Down Expand Up @@ -486,13 +486,10 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)

error:
kfree(c);
kfree(rpl_context->rc);
kfree(rpl_context);
p9_debug(P9_DEBUG_ERROR, "EIO\n");
return -EIO;
err_free1:
kfree(rpl_context->rc);
err_free2:
err_free:
kfree(rpl_context);
err_close:
spin_lock_irqsave(&rdma->req_lock, flags);
Expand Down

0 comments on commit b530e25

Please sign in to comment.