[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251105125713.GC16832@unreal>
Date: Wed, 5 Nov 2025 14:57:13 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: haris.iqbal@...os.com, jinpu.wang@...os.com, jgg@...pe.ca,
danil.kipnis@...ud.ionos.com, linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
stable@...r.kernel.org
Subject: Re: [PATCH] RDMA/rtrs: server: Fix error handling in
get_or_create_srv
On Tue, Nov 04, 2025 at 10:19:00AM +0800, Ma Ke wrote:
> get_or_create_srv() fails to call put_device() after
> device_initialize() when memory allocation fails. This could cause
> reference count leaks during error handling, preventing proper device
> cleanup and resulting in memory leaks.
Nothing from above is true. put_device is preferable way to release
memory after call to device_initialize(), but direct call to kfree is
also fine.
>
> Found by code review.
>
> Cc: stable@...r.kernel.org
There is no need in this line at all, it is not fixing anything.
Please rewrite commit message, thanks.
> Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
> drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> index ef4abdea3c2d..9ecc6343455d 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> @@ -1450,7 +1450,7 @@ static struct rtrs_srv_sess *get_or_create_srv(struct rtrs_srv_ctx *ctx,
> kfree(srv->chunks);
>
> err_free_srv:
> - kfree(srv);
> + put_device(&srv->dev);
> return ERR_PTR(-ENOMEM);
> }
>
> --
> 2.17.1
>
Powered by blists - more mailing lists