mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Greg KH <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH v2] Fix "notes" kobject leak
Date: Tue, 23 Sep 2008 23:51:11 +0400	[thread overview]
Message-ID: <20080923195111.GA22247@x200.localdomain> (raw)
In-Reply-To: <20080915234050.GA10876@suse.de>

> > > > --- a/kernel/module.c
> > > > +++ b/kernel/module.c
> > > > @@ -1174,6 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
> > > >  			sysfs_remove_bin_file(notes_attrs->dir,
> > > >  					      &notes_attrs->attrs[i]);
> > > >  		kobject_del(notes_attrs->dir);
> > > > +		kobject_put(notes_attrs->dir);
> > > 
> > > Hm, no, that should just be a call to kobject_put() instead of
> > > kobject_del(), can you try that instead and see if that solves the issue
> > > (am at a conference and can't test that at the moment, sorry.)
> > 
> > Why?! kobject_del() puts parent kobject.
> 
> And that's about it (well, it also tears down the sysfs stuff.)
> 
> If you call kobject_put() instead, and it's the last put, it will also
> call kobject_del() and do everything else that it needs to do.
> 
> Try it and let me know if I'm right or not :)

OK, this works too.


[PATCH v2] Fix "notes" kobject leak

It happens every rmmod if KALLSYMS=y and SYSFS=y.

	# modprobe foo

kobject: 'foo' (ffffffffa00743d0): kobject_add_internal: parent: 'module', set: 'module'
kobject: 'holders' (ffff88017e7c5770): kobject_add_internal: parent: 'foo', set: '<NULL>'
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'notes' (ffff88017fa9b668): kobject_add_internal: parent: 'foo', set: '<NULL>'
	  ^^^^^

	# rmmod foo

kobject: 'holders' (ffff88017e7c5770): kobject_cleanup
kobject: 'holders' (ffff88017e7c5770): auto cleanup kobject_del
kobject: 'holders' (ffff88017e7c5770): calling ktype release
kobject: (ffff88017e7c5770): dynamic_kobj_release
kobject: 'holders': free name
kobject: 'foo' (ffffffffa00743d0): kobject_cleanup
kobject: 'foo' (ffffffffa00743d0): does not have a release() function, it is broken and must be fixed.
kobject: 'foo' (ffffffffa00743d0): auto cleanup 'remove' event
kobject: 'foo' (ffffffffa00743d0): kobject_uevent_env
kobject: 'foo' (ffffffffa00743d0): fill_kobj_path: path = '/module/foo'
kobject: 'foo' (ffffffffa00743d0): auto cleanup kobject_del
kobject: 'foo': free name

	[whooops]

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 kernel/module.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1173,7 +1173,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
 		while (i-- > 0)
 			sysfs_remove_bin_file(notes_attrs->dir,
 					      &notes_attrs->attrs[i]);
-		kobject_del(notes_attrs->dir);
+		kobject_put(notes_attrs->dir);
 	}
 	kfree(notes_attrs);
 }

  reply	other threads:[~2008-09-23 19:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30  4:42 kobject leak in next-20080829 Alexey Dobriyan
2008-08-30  5:43 ` Greg KH
2008-09-06  5:45   ` kobject leak in next-20080829 (and mainline) Alexey Dobriyan
2008-09-12 15:51     ` Greg KH
2008-09-14  8:42       ` [PATCH] Fix "notes" kobject leak Alexey Dobriyan
2008-09-15 22:53         ` Greg KH
2008-09-15 23:35           ` Alexey Dobriyan
2008-09-15 23:40             ` Greg KH
2008-09-23 19:51               ` Alexey Dobriyan [this message]
2008-09-23 20:56                 ` [PATCH v2] " Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080923195111.GA22247@x200.localdomain \
    --to=adobriyan@gmail.com \
    --cc=akpm@osdl.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®