Skip to content

Commit

Permalink
IB/mlx4: Fix memory leak if QP creation failed
Browse files Browse the repository at this point in the history
When RC, UC, or RAW QPs are created, a qp object is allocated (kzalloc).
If at a later point (in procedure create_qp_common) the qp creation fails,
this qp object must be freed.

Fixes: 1ffeb2e ("IB/mlx4: SR-IOV IB context objects and proxy/tunnel SQP support")
Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Dotan Barak authored and Doug Ledford committed Jun 23, 2016
1 parent 5533c18 commit 5b420d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/infiniband/hw/mlx4/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,10 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
{
err = create_qp_common(to_mdev(pd->device), pd, init_attr,
udata, 0, &qp, gfp);
if (err)
if (err) {
kfree(qp);
return ERR_PTR(err);
}

qp->ibqp.qp_num = qp->mqp.qpn;
qp->xrcdn = xrcdn;
Expand Down

0 comments on commit 5b420d9

Please sign in to comment.