diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-11 04:21:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-11 14:14:22 -0400 |
commit | f33d9bd50478c9a969b65f58feb6b69a3ad478cb (patch) | |
tree | 90f7455da171aa2b7558d5921f199015b5ab9a0b | |
parent | 5a2b4062f5adf2218b9b021e1c33f374bf142cb2 (diff) |
[PATCH] tpm: fix error handling
- handle sysfs error
- handle driver model errors
- de-obfuscate platform_device_register_simple() call, which included an
assignment in between two function calls, in the same C statement.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Acked-by: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/char/tpm/tpm.c | 9 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 10 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_nsc.c | 6 |
3 files changed, 17 insertions, 8 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index a082a2e34252..6ad2d3bb945c 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -1153,7 +1153,14 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend | |||
1153 | 1153 | ||
1154 | spin_unlock(&driver_lock); | 1154 | spin_unlock(&driver_lock); |
1155 | 1155 | ||
1156 | sysfs_create_group(&dev->kobj, chip->vendor.attr_group); | 1156 | if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { |
1157 | list_del(&chip->list); | ||
1158 | put_device(dev); | ||
1159 | clear_bit(chip->dev_num, dev_mask); | ||
1160 | kfree(chip); | ||
1161 | kfree(devname); | ||
1162 | return NULL; | ||
1163 | } | ||
1157 | 1164 | ||
1158 | chip->bios_dir = tpm_bios_log_setup(devname); | 1165 | chip->bios_dir = tpm_bios_log_setup(devname); |
1159 | 1166 | ||
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index ad8ffe49256f..1ab0896070be 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -184,7 +184,9 @@ static int __init init_atmel(void) | |||
184 | unsigned long base; | 184 | unsigned long base; |
185 | struct tpm_chip *chip; | 185 | struct tpm_chip *chip; |
186 | 186 | ||
187 | driver_register(&atml_drv); | 187 | rc = driver_register(&atml_drv); |
188 | if (rc) | ||
189 | return rc; | ||
188 | 190 | ||
189 | if ((iobase = atmel_get_base_addr(&base, ®ion_size)) == NULL) { | 191 | if ((iobase = atmel_get_base_addr(&base, ®ion_size)) == NULL) { |
190 | rc = -ENODEV; | 192 | rc = -ENODEV; |
@@ -195,10 +197,8 @@ static int __init init_atmel(void) | |||
195 | (atmel_request_region | 197 | (atmel_request_region |
196 | (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1; | 198 | (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1; |
197 | 199 | ||
198 | 200 | pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0); | |
199 | if (IS_ERR | 201 | if (IS_ERR(pdev)) { |
200 | (pdev = | ||
201 | platform_device_register_simple("tpm_atmel", -1, NULL, 0))) { | ||
202 | rc = PTR_ERR(pdev); | 202 | rc = PTR_ERR(pdev); |
203 | goto err_rel_reg; | 203 | goto err_rel_reg; |
204 | } | 204 | } |
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 26287aace87d..608f73071bef 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
@@ -284,7 +284,7 @@ static struct device_driver nsc_drv = { | |||
284 | static int __init init_nsc(void) | 284 | static int __init init_nsc(void) |
285 | { | 285 | { |
286 | int rc = 0; | 286 | int rc = 0; |
287 | int lo, hi; | 287 | int lo, hi, err; |
288 | int nscAddrBase = TPM_ADDR; | 288 | int nscAddrBase = TPM_ADDR; |
289 | struct tpm_chip *chip; | 289 | struct tpm_chip *chip; |
290 | unsigned long base; | 290 | unsigned long base; |
@@ -297,7 +297,9 @@ static int __init init_nsc(void) | |||
297 | return -ENODEV; | 297 | return -ENODEV; |
298 | } | 298 | } |
299 | 299 | ||
300 | driver_register(&nsc_drv); | 300 | err = driver_register(&nsc_drv); |
301 | if (err) | ||
302 | return err; | ||
301 | 303 | ||
302 | hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); | 304 | hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); |
303 | lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); | 305 | lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); |