Skip to contentSkip to conversation

kobject: new_device->kref wasn't putted in kobject_move()

PATCH In review Dmitriy Monakhov 1 participant 2 messages Mar 3, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kobject: new_device->kref wasn't putted in kobject_move()

lib/kobject.c +1 -0
index b94f208..b11f7b2 100644
@@ -432,6 +432,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
 	kobject_put(old_parent);
 	kobject_uevent_env(kobj, KOBJ_MOVE, envp);
 out:
+	kobject_put(new_parent);
 	kobject_put(kobj);
 	kfree(devpath_string);
 	kfree(devpath);
#1 lore raw
Quoted 7 lines · Dmitriy Monakhov
lib/kobject.c +0 -0
index b94f208..b11f7b2 100644

lib/kobject.c int kobject_move(struct kobject *kobj, struct kobject *new_parent) · line 438

Quoted 7 lines
lib/kobject.c +1 -0
@@ -432,6 +432,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
 	kobject_put(old_parent);
 	kobject_uevent_env(kobj, KOBJ_MOVE, envp);
 out:
+	kobject_put(new_parent);
 	kobject_put(kobj);
 	kfree(devpath_string);
 	kfree(devpath);

OOps i'm realy sorry, by occasion patch was incomplete :( The updated patch version following:

[PATCH] kobject: new_device->kref wasn't putted after error in kobject_move() If error happen we jump to "out" label, in this case new_device not yet became the parent but it wasn't putted.

lib/kobject.c +2 -0
index b94f208..a6c9a06 100644
@@ -429,9 +429,11 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
 		goto out;
 	old_parent = kobj->parent;
 	kobj->parent = new_parent;
+	new_parent = NULL;
 	kobject_put(old_parent);
 	kobject_uevent_env(kobj, KOBJ_MOVE, envp);
 out:
+	kobject_put(new_parent);
 	kobject_put(kobj);
 	kfree(devpath_string);
 	kfree(devpath);