[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251105145106.GG16832@unreal>
Date: Wed, 5 Nov 2025 16:51:06 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: Ma Ke <make24@...as.ac.cn>, haris.iqbal@...os.com, jinpu.wang@...os.com,
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 Wed, Nov 05, 2025 at 09:46:59AM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 05, 2025 at 02:57:13PM +0200, Leon Romanovsky wrote:
> > 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.
>
> Once device_initialize() happens you must call put_device(), it is one
> of Greg's rules.
According to the documentation it is not must, but is very good to have.
This sentence from above commit message is wrong:
"This could cause reference count leaks during error handling, preventing proper device
cleanup and resulting in memory leaks."
It won't cause to reference count leaks and doesn't have memory leaks in
this flow.
Thanks
>
> Jason
Powered by blists - more mailing lists