From: Tao Cui <cui.tao@linux.dev>
To: leon@kernel.org, jgg@ziepe.ca, linux-rdma@vger.kernel.org
Cc: Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH rdma-next] RDMA/core: Fix FRMR handle leak on push_handle_to_queue_locked failure
Date: Mon, 8 Jun 2026 12:56:57 +0800 [thread overview]
Message-ID: <20260608045657.2715472-1-cui.tao@linux.dev> (raw)
From: Tao Cui <cuitao@kylinos.cn>
In ib_frmr_pools_set_pinned(), after create_frmrs() successfully
allocates handles, the push loop may fail partway through due to
-ENOMEM from kzalloc in push_handle_to_queue_locked(). The remaining
created-but-unpushed handles are silently leaked as they are never
destroyed.
Call destroy_frmrs() for the remaining unpushed handles before returning
the error.
Fixes: ce5df0b891ed ("IB/core: Introduce FRMR pools")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
drivers/infiniband/core/frmr_pools.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/infiniband/core/frmr_pools.c b/drivers/infiniband/core/frmr_pools.c
index 5e992ff3d7cf..d7906fab033f 100644
--- a/drivers/infiniband/core/frmr_pools.c
+++ b/drivers/infiniband/core/frmr_pools.c
@@ -443,6 +443,9 @@ int ib_frmr_pools_set_pinned(struct ib_device *device, struct ib_frmr_key *key,
end:
spin_unlock(&pool->lock);
+ if (ret && i < needed_handles)
+ pools->pool_ops->destroy_frmrs(device, &handles[i],
+ needed_handles - i);
kfree(handles);
schedule_aging:
--
2.43.0
reply other threads:[~2026-06-08 4:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260608045657.2715472-1-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox