Skip to content

Commit fd5382c

Browse files
zhuyjjgunthorpe
authored andcommitted
RDMA/rxe: Fix error unwind in rxe_create_qp()
In the function rxe_create_qp(), rxe_qp_from_init() is called to initialize qp, internally things like the spin locks are not setup until rxe_qp_init_req(). If an error occures before this point then the unwind will call rxe_cleanup() and eventually to rxe_qp_do_cleanup()/rxe_cleanup_task() which will oops when trying to access the uninitialized spinlock. Move the spinlock initializations earlier before any failures. Fixes: 8700e3e ("Soft RoCE driver") Link: https://lore.kernel.org/r/[email protected] Reported-by: [email protected] Signed-off-by: Zhu Yanjun <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c977645 commit fd5382c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/infiniband/sw/rxe/rxe_qp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp,
172172

173173
spin_lock_init(&qp->state_lock);
174174

175+
spin_lock_init(&qp->req.task.state_lock);
176+
spin_lock_init(&qp->resp.task.state_lock);
177+
spin_lock_init(&qp->comp.task.state_lock);
178+
179+
spin_lock_init(&qp->sq.sq_lock);
180+
spin_lock_init(&qp->rq.producer_lock);
181+
spin_lock_init(&qp->rq.consumer_lock);
182+
175183
atomic_set(&qp->ssn, 0);
176184
atomic_set(&qp->skb_out, 0);
177185
}
@@ -232,7 +240,6 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
232240
qp->req.opcode = -1;
233241
qp->comp.opcode = -1;
234242

235-
spin_lock_init(&qp->sq.sq_lock);
236243
skb_queue_head_init(&qp->req_pkts);
237244

238245
rxe_init_task(rxe, &qp->req.task, qp,
@@ -283,9 +290,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
283290
}
284291
}
285292

286-
spin_lock_init(&qp->rq.producer_lock);
287-
spin_lock_init(&qp->rq.consumer_lock);
288-
289293
skb_queue_head_init(&qp->resp_pkts);
290294

291295
rxe_init_task(rxe, &qp->resp.task, qp,

0 commit comments

Comments
 (0)