]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/mana: Fix mana_destroy_wq_obj() cleanup in mana_ib_create_qp_rss()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 28 Apr 2026 16:17:39 +0000 (13:17 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Sat, 2 May 2026 18:30:48 +0000 (15:30 -0300)
Sashiko points out there are two bugs here in the error unwind flow, both
related to how the WQ table is unwound.

First there is a double i-- on the first failure path due to the while loop
having a i--, remove it.

Second if mana_ib_install_cq_cb() fails then mana_create_wq_obj() is not
undone due to the above i--.

Cc: stable@vger.kernel.org
Fixes: c15d7802a424 ("RDMA/mana_ib: Add CQ interrupt support for RAW QP")
Link: https://sashiko.dev/#/patchset/0-v2-1c49eeb88c48%2B91-rdma_udata_rep_jgg%40nvidia.com?part=1
Link: https://patch.msgid.link/r/6-v1-41f3135e5565+9d2-rdma_ai_fixes1_jgg@nvidia.com
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mana/qp.c

index f7bb0d1f0f8034bba6c94ea4f0cbc5a17671ece3..8e1f052d0ec976f2ecf7991774135d4dba234662 100644 (file)
@@ -176,11 +176,8 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,
 
                ret = mana_create_wq_obj(mpc, mpc->port_handle, GDMA_RQ,
                                         &wq_spec, &cq_spec, &wq->rx_object);
-               if (ret) {
-                       /* Do cleanup starting with index i-1 */
-                       i--;
+               if (ret)
                        goto fail;
-               }
 
                /* The GDMA regions are now owned by the WQ object */
                wq->queue.gdma_region = GDMA_INVALID_DMA_REGION;
@@ -200,8 +197,10 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,
 
                /* Create CQ table entry */
                ret = mana_ib_install_cq_cb(mdev, cq);
-               if (ret)
+               if (ret) {
+                       mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object);
                        goto fail;
+               }
        }
        resp.num_entries = i;