kobject: catch kobjects that are not initialized
[safe/jmp/linux-2.6] / lib / kobject.c
index 0d03252..60ae9e8 100644 (file)
@@ -592,8 +592,15 @@ static void kobject_release(struct kref *kref)
  */
 void kobject_put(struct kobject *kobj)
 {
-       if (kobj)
+       if (kobj) {
+               if (!kobj->state_initialized) {
+                       printk(KERN_WARNING "kobject: '%s' (%p): is not "
+                              "initialized, yet kobject_put() is being "
+                              "called.\n", kobject_name(kobj), kobj);
+                       WARN_ON(1);
+               }
                kref_put(&kobj->kref, kobject_release);
+       }
 }
 
 static void dynamic_kobj_release(struct kobject *kobj)