Commit 8a278e6d authored by Ralph Campbell's avatar Ralph Campbell Committed by Roland Dreier

IB/ipath: Fix error path in QP creation

This patch fixes the code which frees the partially allocated QP
resources if there was an error while creating the QP. In particular,
the QPN wasn't deallocated and the QP wasn't removed from the hash
table.
Signed-off-by: default avatarRalph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent fb74dacb
...@@ -835,7 +835,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -835,7 +835,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
init_attr->qp_type); init_attr->qp_type);
if (err) { if (err) {
ret = ERR_PTR(err); ret = ERR_PTR(err);
goto bail_rwq; vfree(qp->r_rq.wq);
goto bail_qp;
} }
qp->ip = NULL; qp->ip = NULL;
ipath_reset_qp(qp); ipath_reset_qp(qp);
...@@ -863,7 +864,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -863,7 +864,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
sizeof(offset)); sizeof(offset));
if (err) { if (err) {
ret = ERR_PTR(err); ret = ERR_PTR(err);
goto bail_rwq; goto bail_ip;
} }
} else { } else {
u32 s = sizeof(struct ipath_rwq) + u32 s = sizeof(struct ipath_rwq) +
...@@ -875,7 +876,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -875,7 +876,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
qp->r_rq.wq); qp->r_rq.wq);
if (!qp->ip) { if (!qp->ip) {
ret = ERR_PTR(-ENOMEM); ret = ERR_PTR(-ENOMEM);
goto bail_rwq; goto bail_ip;
} }
err = ib_copy_to_udata(udata, &(qp->ip->offset), err = ib_copy_to_udata(udata, &(qp->ip->offset),
...@@ -907,9 +908,11 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -907,9 +908,11 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
goto bail; goto bail;
bail_ip: bail_ip:
kfree(qp->ip); if (qp->ip)
bail_rwq: kref_put(&qp->ip->ref, ipath_release_mmap_info);
vfree(qp->r_rq.wq); else
vfree(qp->r_rq.wq);
ipath_free_qp(&dev->qp_table, qp);
bail_qp: bail_qp:
kfree(qp); kfree(qp);
bail_swq: bail_swq:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment