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 <[email protected]>
---
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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]