From: Greg Kroah-Hartman Date: Tue, 26 Feb 2008 17:36:38 +0000 (-0800) Subject: kobject: catch kobjects that are not initialized X-Git-Tag: v2.6.26-rc1~1126^2~35 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c1ebdae514a356c71c09035f5141d94aab5e8fe4;p=karo-tx-linux.git 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 Cc: Hannes Reinecke Signed-off-by: Greg Kroah-Hartman --- 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) */ 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)