lkml.org 
[lkml]   [2020]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] kobject: Avoid premature parent object freeing in kobject_cleanup()
On Mon, Aug 3, 2020 at 10:25 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Mon, Aug 3, 2020 at 9:47 AM Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
> > On 2020/6/5 上午1:46, Rafael J. Wysocki wrote:

> > > +void kobject_del(struct kobject *kobj)
> > > +{
> > > + struct kobject *parent = kobj->parent;
> > > +
> > > + __kobject_del(kobj);
> > > + kobject_put(parent);
> >
> > Could you please add an extra check on kobj before accessing kobj->parent?
>
> I do not understand. Where do we access it?
> kobject_put() is NULL-aware.

Ah, I see, now.

Should be something like
struct kobject *parent = kobj ? kobj->parent : NULL;

> > This patch in fact removes the ability to call kobject_del() on NULL
> > pointer while not cause anything wrong.
> >
> > I know this is not a big deal, but such behavior change has already
> > caused some problem for the incoming btrfs code.
> > (Now I feels guilty just by looking into the old
> > kobject_del()/kobject_put() and utilize that feature in btrfs)
> >
> > Since the old kobject_del() accepts NULL pointer intentionally, it would
> > be much better to keep such behavior.


--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2020-08-03 09:29    [W:0.053 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site