aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-02-26 12:36:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:17 -0400
commitc1ebdae514a356c71c09035f5141d94aab5e8fe4 (patch)
tree28a3a22b01e7b28b0e247a073711923169ddd528
parent3925e6fc1f774048404fdd910b0345b06c699eb4 (diff)
kobject: catch kobjects that are not initialized
Add warnings to kobject_put() to catch kobjects that are cleaned up but were never initialized to begin with. Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--lib/kobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 0d03252f87a8..60ae9e817663 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -592,8 +592,15 @@ static void kobject_release(struct kref *kref)
592 */ 592 */
593void kobject_put(struct kobject *kobj) 593void kobject_put(struct kobject *kobj)
594{ 594{
595 if (kobj) 595 if (kobj) {
596 if (!kobj->state_initialized) {
597 printk(KERN_WARNING "kobject: '%s' (%p): is not "
598 "initialized, yet kobject_put() is being "
599 "called.\n", kobject_name(kobj), kobj);
600 WARN_ON(1);
601 }
596 kref_put(&kobj->kref, kobject_release); 602 kref_put(&kobj->kref, kobject_release);
603 }
597} 604}
598 605
599static void dynamic_kobj_release(struct kobject *kobj) 606static void dynamic_kobj_release(struct kobject *kobj)