From: Praneeth Balasubramanian srp_destroy_qp() calls ib_drain_qp(), which also drains the send queue. ib_drain_sq() requires the caller to "ensure there is room in the CQ and SQ for the drain work request and completion". SRP reserves that room on the receive side, where the queue and CQ have queue_size + 1 entries. Commit 9294000d6d89 ("IB/srp: Drain the send queue before destroying a QP") switched from ib_drain_rq() to ib_drain_qp() but did not grow the send side. The send queue and send CQ hold exactly m * queue_size entries, which is the most work requests SRP can have outstanding. If the channel is torn down while the send queue is full, for example during error handling after a target stops responding, posting the drain work request can fail with "failed to drain send queue", or its completion can find the CQ full. The QP is then destroyed without the guarantee that ib_drain_qp() is meant to provide. Add one entry to the send queue and the send CQ, as nvme-rdma and iser already do. The missing reservation was found with an LLM-based tool that checks callers against the rules stated in kernel comments. Fixes: 9294000d6d89 ("IB/srp: Drain the send queue before destroying a QP") Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche Signed-off-by: Praneeth Balasubramanian --- Notes: v2: - No code change. - The author now matches the Signed-off-by. v1 went out with the gmail address as the From: header. - Added Bart's Reviewed-by and Cc: stable. This was found by an LLM-based static analysis (GPT-5.6) that checks kernel code against the rules stated in its comments, as part of research at UCSB SecLab. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64). Not runtime-tested. I do not have an SRP target setup, and I have not observed the drain failure myself. The change only follows the ib_drain_sq() contract and matches the receive side and nvme-rdma. The patch applies to mainline 9ba46df34488 and to next-20261116. drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 955f36efeebd3..2cd0b728424e2 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -546,7 +546,8 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) goto err; } - send_cq = ib_alloc_cq(dev->dev, ch, m * target->queue_size, + /* m * queue_size + 1 for ib_drain_sq() */ + send_cq = ib_alloc_cq(dev->dev, ch, m * target->queue_size + 1, ch->comp_vector, IB_POLL_DIRECT); if (IS_ERR(send_cq)) { ret = PTR_ERR(send_cq); @@ -554,7 +555,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) } init_attr->event_handler = srp_qp_event; - init_attr->cap.max_send_wr = m * target->queue_size; + init_attr->cap.max_send_wr = m * target->queue_size + 1; init_attr->cap.max_recv_wr = target->queue_size + 1; init_attr->cap.max_recv_sge = 1; init_attr->cap.max_send_sge = min(attr->max_send_sge, SRP_MAX_SGE); -- 2.25.1