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/s390 | |
| 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/s390')
| -rw-r--r-- | drivers/s390/cio/ccwgroup.c | 3 | ||||
| -rw-r--r-- | drivers/s390/cio/device.c | 25 | ||||
| -rw-r--r-- | drivers/s390/crypto/ap_bus.c | 14 |
3 files changed, 12 insertions, 30 deletions
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index b0a18f5176..5d967c4398 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c | |||
| @@ -44,8 +44,7 @@ ccwgroup_bus_match (struct device * dev, struct device_driver * drv) | |||
| 44 | return 0; | 44 | return 0; |
| 45 | } | 45 | } |
| 46 | static int | 46 | static int |
| 47 | ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer, | 47 | ccwgroup_uevent (struct device *dev, struct kobj_uevent_env *env) |
| 48 | int buffer_size) | ||
| 49 | { | 48 | { |
| 50 | /* TODO */ | 49 | /* TODO */ |
| 51 | return 0; | 50 | return 0; |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index e44d92eac8..606bb53e9f 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
| @@ -78,49 +78,38 @@ static int snprint_alias(char *buf, size_t size, | |||
| 78 | 78 | ||
| 79 | /* Set up environment variables for ccw device uevent. Return 0 on success, | 79 | /* Set up environment variables for ccw device uevent. Return 0 on success, |
| 80 | * non-zero otherwise. */ | 80 | * non-zero otherwise. */ |
| 81 | static int ccw_uevent(struct device *dev, char **envp, int num_envp, | 81 | static int ccw_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 82 | char *buffer, int buffer_size) | ||
| 83 | { | 82 | { |
| 84 | struct ccw_device *cdev = to_ccwdev(dev); | 83 | struct ccw_device *cdev = to_ccwdev(dev); |
| 85 | struct ccw_device_id *id = &(cdev->id); | 84 | struct ccw_device_id *id = &(cdev->id); |
| 86 | int i = 0; | ||
| 87 | int len = 0; | ||
| 88 | int ret; | 85 | int ret; |
| 89 | char modalias_buf[30]; | 86 | char modalias_buf[30]; |
| 90 | 87 | ||
| 91 | /* CU_TYPE= */ | 88 | /* CU_TYPE= */ |
| 92 | ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 89 | ret = add_uevent_var(env, "CU_TYPE=%04X", id->cu_type); |
| 93 | "CU_TYPE=%04X", id->cu_type); | ||
| 94 | if (ret) | 90 | if (ret) |
| 95 | return ret; | 91 | return ret; |
| 96 | 92 | ||
| 97 | /* CU_MODEL= */ | 93 | /* CU_MODEL= */ |
| 98 | ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 94 | ret = add_uevent_var(env, "CU_MODEL=%02X", id->cu_model); |
| 99 | "CU_MODEL=%02X", id->cu_model); | ||
| 100 | if (ret) | 95 | if (ret) |
| 101 | return ret; | 96 | return ret; |
| 102 | 97 | ||
| 103 | /* The next two can be zero, that's ok for us */ | 98 | /* The next two can be zero, that's ok for us */ |
| 104 | /* DEV_TYPE= */ | 99 | /* DEV_TYPE= */ |
| 105 | ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 100 | ret = add_uevent_var(env, "DEV_TYPE=%04X", id->dev_type); |
| 106 | "DEV_TYPE=%04X", id->dev_type); | ||
| 107 | if (ret) | 101 | if (ret) |
| 108 | return ret; | 102 | return ret; |
| 109 | 103 | ||
| 110 | /* DEV_MODEL= */ | 104 | /* DEV_MODEL= */ |
| 111 | ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 105 | ret = add_uevent_var(env, "DEV_MODEL=%02X", id->dev_model); |
| 112 | "DEV_MODEL=%02X", id->dev_model); | ||
| 113 | if (ret) | 106 | if (ret) |
| 114 | return ret; | 107 | return ret; |
| 115 | 108 | ||
| 116 | /* MODALIAS= */ | 109 | /* MODALIAS= */ |
| 117 | snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); | 110 | snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); |
| 118 | ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, | 111 | ret = add_uevent_var(env, "MODALIAS=%s", modalias_buf); |
| 119 | "MODALIAS=%s", modalias_buf); | 112 | return ret; |
| 120 | if (ret) | ||
| 121 | return ret; | ||
| 122 | envp[i] = NULL; | ||
| 123 | return 0; | ||
| 124 | } | 113 | } |
| 125 | 114 | ||
| 126 | struct bus_type ccw_bus_type; | 115 | struct bus_type ccw_bus_type; |
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 90bd220145..e997130415 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
| @@ -458,28 +458,22 @@ static int ap_bus_match(struct device *dev, struct device_driver *drv) | |||
| 458 | * uevent function for AP devices. It sets up a single environment | 458 | * uevent function for AP devices. It sets up a single environment |
| 459 | * variable DEV_TYPE which contains the hardware device type. | 459 | * variable DEV_TYPE which contains the hardware device type. |
| 460 | */ | 460 | */ |
| 461 | static int ap_uevent (struct device *dev, char **envp, int num_envp, | 461 | static int ap_uevent (struct device *dev, struct kobj_uevent_env *env) |
| 462 | char *buffer, int buffer_size) | ||
| 463 | { | 462 | { |
| 464 | struct ap_device *ap_dev = to_ap_dev(dev); | 463 | struct ap_device *ap_dev = to_ap_dev(dev); |
| 465 | int retval = 0, length = 0, i = 0; | 464 | int retval = 0; |
| 466 | 465 | ||
| 467 | if (!ap_dev) | 466 | if (!ap_dev) |
| 468 | return -ENODEV; | 467 | return -ENODEV; |
| 469 | 468 | ||
| 470 | /* Set up DEV_TYPE environment variable. */ | 469 | /* Set up DEV_TYPE environment variable. */ |
| 471 | retval = add_uevent_var(envp, num_envp, &i, | 470 | retval = add_uevent_var(env, "DEV_TYPE=%04X", ap_dev->device_type); |
| 472 | buffer, buffer_size, &length, | ||
| 473 | "DEV_TYPE=%04X", ap_dev->device_type); | ||
| 474 | if (retval) | 471 | if (retval) |
| 475 | return retval; | 472 | return retval; |
| 476 | 473 | ||
| 477 | /* Add MODALIAS= */ | 474 | /* Add MODALIAS= */ |
| 478 | retval = add_uevent_var(envp, num_envp, &i, | 475 | retval = add_uevent_var(env, "MODALIAS=ap:t%02X", ap_dev->device_type); |
| 479 | buffer, buffer_size, &length, | ||
| 480 | "MODALIAS=ap:t%02X", ap_dev->device_type); | ||
| 481 | 476 | ||
| 482 | envp[i] = NULL; | ||
| 483 | return retval; | 477 | return retval; |
| 484 | } | 478 | } |
| 485 | 479 | ||
