From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>, Greg K-H <greg@kroah.com>,
Tejun Heo <htejun@gmail.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: [Patch -mm 3/3] RFC: Introduce kobject->owner for refcounting.
Date: Mon, 16 Apr 2007 19:36:27 +0200 [thread overview]
Message-ID: <20070416193627.1db62136@gondolin.boeblingen.de.ibm.com> (raw)
Grab and release the module kobject refcount if kobj->owner is set.
This prevents calls to the release function after the module has
been unloaded.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
include/linux/kobject.h | 1 +
lib/kobject.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
--- linux-2.6.orig/include/linux/kobject.h
+++ linux-2.6/include/linux/kobject.h
@@ -51,6 +51,7 @@ enum kobject_action {
};
struct kobject {
+ struct module * owner;
const char * k_name;
char name[KOBJ_NAME_LEN];
struct kref kref;
--- linux-2.6.orig/lib/kobject.c
+++ linux-2.6/lib/kobject.c
@@ -177,6 +177,8 @@ void kobject_init(struct kobject * kobj)
INIT_LIST_HEAD(&kobj->entry);
init_waitqueue_head(&kobj->poll);
kobj->kset = kset_get(kobj->kset);
+ /* Attempt to grab reference of owning module's kobject. */
+ mod_kobject_get(kobj->owner);
}
@@ -254,6 +256,7 @@ int kobject_shadow_add(struct kobject *
printk("kobject_add failed for %s (%d)\n",
kobject_name(kobj), error);
dump_stack();
+ mod_kobject_put(kobj->owner);
}
return error;
@@ -491,6 +494,7 @@ void kobject_cleanup(struct kobject * ko
struct kobj_type * t = get_ktype(kobj);
struct kset * s = kobj->kset;
struct kobject * parent = kobj->parent;
+ struct module * owner = kobj->owner;
pr_debug("kobject %s: cleaning up\n",kobject_name(kobj));
if (kobj->k_name != kobj->name)
@@ -503,7 +507,7 @@ void kobject_cleanup(struct kobject * ko
"if this is not a directory kobject, it is broken "
"and must be fixed.\n",
kobj->name);
-
+ mod_kobject_put(owner);
if (s)
kset_put(s);
kobject_put(parent);
next reply other threads:[~2007-04-16 17:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-16 17:36 Cornelia Huck [this message]
2007-04-16 18:05 ` Greg KH
2007-04-16 19:53 ` Alan Stern
2007-04-17 2:53 ` Rusty Russell
2007-04-17 7:16 ` Cornelia Huck
2007-04-17 16:08 ` Alan Stern
2007-04-17 23:55 ` Rusty Russell
2007-04-18 15:20 ` Alan Stern
2007-04-19 0:46 ` Rusty Russell
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=20070416193627.1db62136@gondolin.boeblingen.de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=greg@kroah.com \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=stern@rowland.harvard.edu \
/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®