Re: [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 14 Mar 2025 09:42:31 -0400 Gregory Price <gourry@xxxxxxxxxx> 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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux