]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/core: Fix FRMR set pinned push error path
authorMichael Guralnik <michaelgur@nvidia.com>
Wed, 10 Jun 2026 00:01:41 +0000 (03:01 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 11 Jun 2026 18:36:08 +0000 (15:36 -0300)
Add destruction of FRMR handles in case the push to the pool fails.
This prevents resources leak in case pool page allocation fails.

Fixes: 020d189d16a6 ("RDMA/core: Add pinned handles to FRMR pools")
Link: https://patch.msgid.link/r/20260610000145.820592-6-michaelgur@nvidia.com
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/frmr_pools.c

index 927642c06f3a4c5fe5151a6316562740dbcadf7c..1cfdddc3fcdaf6c5cf96ec95247d6b8c15f92847 100644 (file)
@@ -461,11 +461,16 @@ int ib_frmr_pools_set_pinned(struct ib_device *device, struct ib_frmr_key *key,
                ret = push_handle_to_queue_locked(&pool->queue,
                                                  handles[i]);
                if (ret)
-                       goto end;
+                       break;
        }
-
-end:
        spin_unlock(&pool->lock);
+
+       if (ret) {
+               /* Destroy handles created but never pushed to the pool. */
+               pools->pool_ops->destroy_frmrs(device, &handles[i],
+                               needed_handles - i);
+       }
+
        kfree(handles);
 
 schedule_aging: