[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250317082406.818-1-rakie.kim@sk.com>
Date: Mon, 17 Mar 2025 17:24:00 +0900
From: Rakie Kim <rakie.kim@...com>
To: Gregory Price <gourry@...rry.net>
Cc: Rakie Kim <rakie.kim@...com>,
akpm@...ux-foundation.org,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
linux-cxl@...r.kernel.org,
joshua.hahnjy@...il.com,
dan.j.williams@...el.com,
ying.huang@...ux.alibaba.com,
kernel_team@...ynix.com,
honggyu.kim@...com,
yunjeong.mun@...com,
Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init()
On Fri, 14 Mar 2025 09:42:31 -0400 Gregory Price <gourry@...rry.net> wrote:
> On Fri, Mar 14, 2025 at 10:55:00AM +0000, Jonathan Cameron wrote:
> > >
> > > 1) allocate node_attrs and mempolicy_kobj up front and keep your
> > > reordering, this lets us clean up allocations on failure before
> > > kobject_init is called
> > >
> > > 2) after this remove all the other code and just let
> > > mempolicy_kobj_release clean up node_attrs
> > >
> > > 3) Add a (%d) to the error message to differentiate failures
> >
> > Given how unlikely (and noisy) a memory allocation failure is,
> > maybe just drop the printing at all in those paths - allowing
> > early returns.
> >
> > The lifetime rules around node_attrs in here are making readability
> > poor. It is implicitly owned by the mempolicy_kobj, but no direct association.
> > Maybe just encapsulating the kobject in a structure that contains
> > this as a [] array at the end. Then we end up with single allocation of
> > stuff that is effectively one thing.
> >
>
> Even better recommendation, lets do as Jonathan suggests. <3
>
> ~Gregory
Hi Gregory
I will revise the next version based on Jonathan's feedback.
Moreover, I'll separate this patch from the hotplug series and make it an
independent patch.
Rakie
Powered by blists - more mailing lists