All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Shuhao Fu <sfual@cse.ust.hk>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RDMA/uverbs: fix umem release in UVERBS_METHOD_CQ_CREATE
Date: Thu, 9 Oct 2025 21:48:54 +0300	[thread overview]
Message-ID: <20251009184854.GB14552@unreal> (raw)
In-Reply-To: <aOflenF0XHtm80G9@homelab>

On Fri, Oct 10, 2025 at 12:40:26AM +0800, Shuhao Fu wrote:
> In `UVERBS_METHOD_CQ_CREATE`, umem should be released if anything goes
> wrong. Currently, if `create_cq_umem` fails, umem would not be
> released or referenced, causing a possible leak.

It is only partially true. UMEM is released inside .create_cq_umem()
implementation. However there is an issue there that it doesn't release
in all flows. You need to change efa_create_cq_umem() too.

> 
> Fixes: 1a40c362ae26 ("RDMA/uverbs: Add a common way to create CQ with umem")
> Signed-off-by: Shuhao Fu <sfual@cse.ust.hk>
> ---
>  drivers/infiniband/core/uverbs_std_types_cq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_std_types_cq.c b/drivers/infiniband/core/uverbs_std_types_cq.c
> index 37cd37556510..9344020dede1 100644
> --- a/drivers/infiniband/core/uverbs_std_types_cq.c
> +++ b/drivers/infiniband/core/uverbs_std_types_cq.c
> @@ -193,8 +193,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
>  
>  	ret = umem ? ib_dev->ops.create_cq_umem(cq, &attr, umem, attrs) :
>  		ib_dev->ops.create_cq(cq, &attr, attrs);
> -	if (ret)
> +	if (ret) {
> +		ib_umem_release(umem);
>  		goto err_free;
> +	}
>  
>  	obj->uevent.uobject.object = cq;
>  	obj->uevent.uobject.user_handle = user_handle;
> -- 
> 2.39.5
> 
> 

  reply	other threads:[~2025-10-09 18:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 16:40 [PATCH] RDMA/uverbs: fix umem release in UVERBS_METHOD_CQ_CREATE Shuhao Fu
2025-10-09 18:48 ` Leon Romanovsky [this message]
2025-10-10  7:37   ` Shuhao Fu

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=20251009184854.GB14552@unreal \
    --to=leon@kernel.org \
    --cc=jgg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sfual@cse.ust.hk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.