lkml.org 
[lkml]   [2024]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug in sysfs_break_active_protection()
Sorry about late reply.

On Mon, Mar 04, 2024 at 02:17:27PM -0500, Alan Stern wrote:
..
> struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
> const struct attribute *attr)
> {
> struct kernfs_node *kn;
>
> kobject_get(kobj);
> kn = kernfs_find_and_get(kobj->sd, attr->name);
> if (kn)
> kernfs_break_active_protection(kn);
> return kn;
> }
..
> If kn is NULL then the kobject_get(kobj) reference is never dropped.
> It looks like this could happen if two processes want to unregister the
> same kobject at the same time.
>
> Shouldn't sysfs_break_active_protection() do this?
>
> kobject_get(kobj);
> kn = kernfs_find_and_get(kobj->sd, attr->name);
> if (kn)
> kernfs_break_active_protection(kn);
> + else
> + kobject_put(kobj);
> return kn;

Yeah, I think you're right. It's an obvious ref leak. Would you mind writing
up a patch?

Thank you.

--
tejun

\
 
 \ /
  Last update: 2024-03-13 21:21    [W:0.071 / U:0.964 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site