aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-08-14 09:15:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:51:01 -0400
commit7eff2e7a8b65c25920207324e56611150eb1cd9a (patch)
tree02a0eeba9d25d996233e30c18f258dfae0ae2139 /net
parent8380770c842faef3001e44662953d64ad9a93663 (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 'net')
-rw-r--r--net/atm/atm_sysfs.c7
-rw-r--r--net/core/net-sysfs.c14
-rw-r--r--net/wireless/sysfs.c3
3 files changed, 7 insertions, 17 deletions
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index f094a0879c1..9ef07eda2c4 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -105,10 +105,9 @@ static struct class_device_attribute *atm_attrs[] = {
105 NULL 105 NULL
106}; 106};
107 107
108static int atm_uevent(struct class_device *cdev, char **envp, int num_envp, char *buf, int size) 108static int atm_uevent(struct class_device *cdev, struct kobj_uevent_env *env)
109{ 109{
110 struct atm_dev *adev; 110 struct atm_dev *adev;
111 int i = 0, len = 0;
112 111
113 if (!cdev) 112 if (!cdev)
114 return -ENODEV; 113 return -ENODEV;
@@ -117,11 +116,9 @@ static int atm_uevent(struct class_device *cdev, char **envp, int num_envp, char
117 if (!adev) 116 if (!adev)
118 return -ENODEV; 117 return -ENODEV;
119 118
120 if (add_uevent_var(envp, num_envp, &i, buf, size, &len, 119 if (add_uevent_var(env, "NAME=%s%d", adev->type, adev->number))
121 "NAME=%s%d", adev->type, adev->number))
122 return -ENOMEM; 120 return -ENOMEM;
123 121
124 envp[i] = NULL;
125 return 0; 122 return 0;
126} 123}
127 124
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 909a03d6c0e..6628e457ddc 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -396,28 +396,22 @@ static struct attribute_group wireless_group = {
396#endif /* CONFIG_SYSFS */ 396#endif /* CONFIG_SYSFS */
397 397
398#ifdef CONFIG_HOTPLUG 398#ifdef CONFIG_HOTPLUG
399static int netdev_uevent(struct device *d, char **envp, 399static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
400 int num_envp, char *buf, int size)
401{ 400{
402 struct net_device *dev = to_net_dev(d); 401 struct net_device *dev = to_net_dev(d);
403 int retval, len = 0, i = 0; 402 int retval;
404 403
405 /* pass interface to uevent. */ 404 /* pass interface to uevent. */
406 retval = add_uevent_var(envp, num_envp, &i, 405 retval = add_uevent_var(env, "INTERFACE=%s", dev->name);
407 buf, size, &len,
408 "INTERFACE=%s", dev->name);
409 if (retval) 406 if (retval)
410 goto exit; 407 goto exit;
411 408
412 /* pass ifindex to uevent. 409 /* pass ifindex to uevent.
413 * ifindex is useful as it won't change (interface name may change) 410 * ifindex is useful as it won't change (interface name may change)
414 * and is what RtNetlink uses natively. */ 411 * and is what RtNetlink uses natively. */
415 retval = add_uevent_var(envp, num_envp, &i, 412 retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
416 buf, size, &len,
417 "IFINDEX=%d", dev->ifindex);
418 413
419exit: 414exit:
420 envp[i] = NULL;
421 return retval; 415 return retval;
422} 416}
423#endif 417#endif
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 2d5d2255a27..29f820e1825 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -53,8 +53,7 @@ static void wiphy_dev_release(struct device *dev)
53} 53}
54 54
55#ifdef CONFIG_HOTPLUG 55#ifdef CONFIG_HOTPLUG
56static int wiphy_uevent(struct device *dev, char **envp, 56static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env)
57 int num_envp, char *buf, int size)
58{ 57{
59 /* TODO, we probably need stuff here */ 58 /* TODO, we probably need stuff here */
60 return 0; 59 return 0;