diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-08-14 09:15:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:01 -0400 |
commit | 7eff2e7a8b65c25920207324e56611150eb1cd9a (patch) | |
tree | 02a0eeba9d25d996233e30c18f258dfae0ae2139 /drivers/ieee1394/nodemgr.c | |
parent | 8380770c842faef3001e44662953d64ad9a93663 (diff) |
Driver core: change add_uevent_var to use a struct
This changes the uevent buffer functions to use a struct instead of a
long list of parameters. It does no longer require the caller to do the
proper buffer termination and size accounting, which is currently wrong
in some places. It fixes a known bug where parts of the uevent
environment are overwritten because of wrong index calculations.
Many thanks to Mathieu Desnoyers for finding bugs and improving the
error handling.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/ieee1394/nodemgr.c')
-rw-r--r-- | drivers/ieee1394/nodemgr.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 2ffd53461db6..1939fee616ec 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -153,8 +153,7 @@ struct host_info { | |||
153 | }; | 153 | }; |
154 | 154 | ||
155 | static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); | 155 | static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); |
156 | static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, | 156 | static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env); |
157 | char *buffer, int buffer_size); | ||
158 | static void nodemgr_resume_ne(struct node_entry *ne); | 157 | static void nodemgr_resume_ne(struct node_entry *ne); |
159 | static void nodemgr_remove_ne(struct node_entry *ne); | 158 | static void nodemgr_remove_ne(struct node_entry *ne); |
160 | static struct node_entry *find_entry_by_guid(u64 guid); | 159 | static struct node_entry *find_entry_by_guid(u64 guid); |
@@ -1160,12 +1159,9 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent | |||
1160 | 1159 | ||
1161 | #ifdef CONFIG_HOTPLUG | 1160 | #ifdef CONFIG_HOTPLUG |
1162 | 1161 | ||
1163 | static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, | 1162 | static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env) |
1164 | char *buffer, int buffer_size) | ||
1165 | { | 1163 | { |
1166 | struct unit_directory *ud; | 1164 | struct unit_directory *ud; |
1167 | int i = 0; | ||
1168 | int length = 0; | ||
1169 | int retval = 0; | 1165 | int retval = 0; |
1170 | /* ieee1394:venNmoNspNverN */ | 1166 | /* ieee1394:venNmoNspNverN */ |
1171 | char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; | 1167 | char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; |
@@ -1180,9 +1176,7 @@ static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, | |||
1180 | 1176 | ||
1181 | #define PUT_ENVP(fmt,val) \ | 1177 | #define PUT_ENVP(fmt,val) \ |
1182 | do { \ | 1178 | do { \ |
1183 | retval = add_uevent_var(envp, num_envp, &i, \ | 1179 | retval = add_uevent_var(env, fmt, val); \ |
1184 | buffer, buffer_size, &length, \ | ||
1185 | fmt, val); \ | ||
1186 | if (retval) \ | 1180 | if (retval) \ |
1187 | return retval; \ | 1181 | return retval; \ |
1188 | } while (0) | 1182 | } while (0) |
@@ -1201,15 +1195,12 @@ do { \ | |||
1201 | 1195 | ||
1202 | #undef PUT_ENVP | 1196 | #undef PUT_ENVP |
1203 | 1197 | ||
1204 | envp[i] = NULL; | ||
1205 | |||
1206 | return 0; | 1198 | return 0; |
1207 | } | 1199 | } |
1208 | 1200 | ||
1209 | #else | 1201 | #else |
1210 | 1202 | ||
1211 | static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, | 1203 | static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env) |
1212 | char *buffer, int buffer_size) | ||
1213 | { | 1204 | { |
1214 | return -ENODEV; | 1205 | return -ENODEV; |
1215 | } | 1206 | } |