Skip to content

Commit

Permalink
kobject: catch kobjects that are not initialized
Browse files Browse the repository at this point in the history
Add warnings to kobject_put() to catch kobjects that are cleaned up but
were never initialized to begin with.

Cc: Kay Sievers <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Apr 20, 2008
1 parent 3925e6f commit c1ebdae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1ebdae

Please sign in to comment.