Commit 5993b75d authored by Bob Pearson's avatar Bob Pearson Committed by Jason Gunthorpe
Browse files

RDMA/rxe: Fix unsafe drain work queue code

If create_qp does not fully succeed it is possible for qp cleanup
code to attempt to drain the send or recv work queues before the
queues have been created causing a seg fault. This patch checks
to see if the queues exist before attempting to drain them.

Link: https://lore.kernel.org/r/20230620135519.9365-3-rpearsonhpe@gmail.com


Reported-by: default avatar <syzbot+2da1965168e7dbcba136@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/linux-rdma/00000000000012d89205fe7cfe00@google.com/raw


Fixes: 49dc9c1f ("RDMA/rxe: Cleanup reset state handling in rxe_resp.c")
Fixes: fbdeb828 ("RDMA/rxe: Cleanup error state handling in rxe_comp.c")
Signed-off-by: default avatarBob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent e0ba8ff4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -597,6 +597,10 @@ static void flush_send_queue(struct rxe_qp *qp, bool notify)
	struct rxe_queue *q = qp->sq.queue;
	int err;

	/* send queue never got created. nothing to do. */
	if (!qp->sq.queue)
		return;

	while ((wqe = queue_head(q, q->type))) {
		if (notify) {
			err = flush_send_wqe(qp, wqe);
+4 −0
Original line number Diff line number Diff line
@@ -1469,6 +1469,10 @@ static void flush_recv_queue(struct rxe_qp *qp, bool notify)
		return;
	}

	/* recv queue not created. nothing to do. */
	if (!qp->rq.queue)
		return;

	while ((wqe = queue_head(q, q->type))) {
		if (notify) {
			err = flush_recv_wqe(qp, wqe);