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>
This commit is contained in:
parent
3925e6fc1f
commit
c1ebdae514
1 changed files with 8 additions and 1 deletions
|
@ -592,8 +592,15 @@ static void kobject_release(struct kref *kref)
|
||||||
*/
|
*/
|
||||||
void kobject_put(struct kobject *kobj)
|
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);
|
kref_put(&kobj->kref, kobject_release);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dynamic_kobj_release(struct kobject *kobj)
|
static void dynamic_kobj_release(struct kobject *kobj)
|
||||||
|
|
Loading…
Reference in a new issue