kobjects: Transmit return value of kobject_uevent_env() to caller
Subsystems (2)
PATCH 2/2 kobjects: Transmit return value of kobject_uevent_env() to caller
The error signal shouldn't be dropped.
---
lib/kobject.c +2 -2
@@ -430,7 +430,7 @@ int kobject_rename(struct kobject *kobj, const char *new_name)* Some hotplug package track interfaces by their name and * therefore want to know when the name is changed by the user. */ if (!error) -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kfree (devpath_string);
@@ -482,7 +482,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) kobj->parent = new_parent; new_parent =NULL ;kobject_put (old_parent); -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kobject_put (new_parent);kobject_put (kobj);
Quoted 21 lines · Wang Chen
The error signal shouldn't be dropped.
Signed-off-by Wang Chen <[email protected]>---
lib/kobject.c +1
-1@@ -430,7 +430,7 @@ int kobject_rename(struct kobject *kobj, const char *new_name)* Some hotplug package track interfaces by their name and * therefore want to know when the name is changed by the user. */ if (!error) -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kfree (devpath_string);
lib/kobject.c int kobject_move(struct kobject *kobj, struct kobject *new_parent) · line 488
Quoted 8 lines
lib/kobject.c +1
-1@@ -482,7 +482,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) kobj->parent = new_parent; new_parent =NULL ;kobject_put (old_parent); -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kobject_put (new_parent);kobject_put (kobj);
This looks wrong. If everything went right except sending the uevent, you'll make the caller believe that the whole operation failed, while in reality the sysfs operation succeeded. Either just drop the error again (or print a warning), or undo the previous operations on error (which may fail).
A message that is not in the archive (sent off-list or not yet received): [email protected]
Cornelia Huck said the following on 2008-6-24 22:24:
Quoted 31 lines
Quoted 31 lines
Quoted 28 lines · Wang Chen
Quoted 28 lines
The error signal shouldn't be dropped.
Signed-off-by Wang Chen <[email protected]>---
lib/kobject.c +2
-2@@ -430,7 +430,7 @@ int kobject_rename(struct kobject *kobj, const char *new_name)* Some hotplug package track interfaces by their name and * therefore want to know when the name is changed by the user. */ if (!error) -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kfree (devpath_string);@@ -482,7 +482,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) kobj->parent = new_parent; new_parent =NULL ;kobject_put (old_parent); -kobject_uevent_env (kobj,KOBJ_MOVE , envp); + error =kobject_uevent_env (kobj,KOBJ_MOVE , envp); out:kobject_put (new_parent);kobject_put (kobj);
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
This looks wrong. If everything went right except sending the uevent, you'll make the caller believe that the whole operation failed, while in reality the sysfs operation succeeded. Either just drop the error again (or print a warning), or undo the previous operations on error (which may fail).
It's depended on how important sending uevent is. If the sysfs operation succeeds, but user-space don't get the notification. Is it ok?
Quoted 3 lines · Wang Chen
It's depended on how important sending uevent is. If the sysfs operation succeeds, but user-space don't get the notification. Is it ok?
Given that (a) there may be no listener, (b) sending via netlink may succeed but calling uevent_helper may fail (highly unlikely the way modern distros are set up, though), and (c) you would have to audit a myriad places that don't check for the return code of kobject_uevent() today as well, it looks like the best way is to simply add some pr_debug()s to kobject_uevent_env() where something fails.
Cornelia Huck said the following on 2008-7-1 18:51:
Quoted 7 lines
Quoted 3 lines · Wang Chen
It's depended on how important sending uevent is. If the sysfs operation succeeds, but user-space don't get the notification. Is it ok?
Quoted 7 lines
Given that (a) there may be no listener, (b) sending via netlink may succeed but calling
uevent_helpermay fail (highly unlikely the way modern distros are set up, though), and (c) you would have to audit a myriad places that don't check for the return code ofkobject_uevent()today as well, it looks like the best way is to simply add some pr_debug()s tokobject_uevent_env()where something fails.
Fair enough. Thanks Cornelia.
Greg, please ignore this patch.
But please take a look at "[PATCH 1/2] kobjects: Transmit return value of call_usermodehelper() to caller".