diff options
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index e3919c353f3d..303f15880466 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -162,7 +162,8 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, | |||
162 | < READ_PCR_RESULT_SIZE){ | 162 | < READ_PCR_RESULT_SIZE){ |
163 | dev_dbg(chip->dev, "A TPM error (%d) occurred" | 163 | dev_dbg(chip->dev, "A TPM error (%d) occurred" |
164 | " attempting to read PCR %d of %d\n", | 164 | " attempting to read PCR %d of %d\n", |
165 | be32_to_cpu(*((__be32 *) (data + 6))), i, num_pcrs); | 165 | be32_to_cpu(*((__be32 *) (data + 6))), |
166 | i, num_pcrs); | ||
166 | goto out; | 167 | goto out; |
167 | } | 168 | } |
168 | str += sprintf(str, "PCR-%02d: ", i); | 169 | str += sprintf(str, "PCR-%02d: ", i); |
@@ -194,12 +195,11 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, | |||
194 | if (chip == NULL) | 195 | if (chip == NULL) |
195 | return -ENODEV; | 196 | return -ENODEV; |
196 | 197 | ||
197 | data = kmalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL); | 198 | data = kzalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL); |
198 | if (!data) | 199 | if (!data) |
199 | return -ENOMEM; | 200 | return -ENOMEM; |
200 | 201 | ||
201 | memcpy(data, readpubek, sizeof(readpubek)); | 202 | memcpy(data, readpubek, sizeof(readpubek)); |
202 | memset(data + sizeof(readpubek), 0, 20); /* zero nonce */ | ||
203 | 203 | ||
204 | if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) < | 204 | if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) < |
205 | READ_PUBEK_RESULT_SIZE) { | 205 | READ_PUBEK_RESULT_SIZE) { |
@@ -243,7 +243,6 @@ out: | |||
243 | kfree(data); | 243 | kfree(data); |
244 | return rc; | 244 | return rc; |
245 | } | 245 | } |
246 | |||
247 | EXPORT_SYMBOL_GPL(tpm_show_pubek); | 246 | EXPORT_SYMBOL_GPL(tpm_show_pubek); |
248 | 247 | ||
249 | #define CAP_VER_RESULT_SIZE 18 | 248 | #define CAP_VER_RESULT_SIZE 18 |
@@ -312,7 +311,6 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | |||
312 | } | 311 | } |
313 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | 312 | EXPORT_SYMBOL_GPL(tpm_store_cancel); |
314 | 313 | ||
315 | |||
316 | /* | 314 | /* |
317 | * Device file system interface to the TPM | 315 | * Device file system interface to the TPM |
318 | */ | 316 | */ |
@@ -336,8 +334,7 @@ int tpm_open(struct inode *inode, struct file *file) | |||
336 | } | 334 | } |
337 | 335 | ||
338 | if (chip->num_opens) { | 336 | if (chip->num_opens) { |
339 | dev_dbg(chip->dev, | 337 | dev_dbg(chip->dev, "Another process owns this TPM\n"); |
340 | "Another process owns this TPM\n"); | ||
341 | rc = -EBUSY; | 338 | rc = -EBUSY; |
342 | goto err_out; | 339 | goto err_out; |
343 | } | 340 | } |
@@ -363,7 +360,6 @@ err_out: | |||
363 | spin_unlock(&driver_lock); | 360 | spin_unlock(&driver_lock); |
364 | return rc; | 361 | return rc; |
365 | } | 362 | } |
366 | |||
367 | EXPORT_SYMBOL_GPL(tpm_open); | 363 | EXPORT_SYMBOL_GPL(tpm_open); |
368 | 364 | ||
369 | int tpm_release(struct inode *inode, struct file *file) | 365 | int tpm_release(struct inode *inode, struct file *file) |
@@ -380,10 +376,9 @@ int tpm_release(struct inode *inode, struct file *file) | |||
380 | spin_unlock(&driver_lock); | 376 | spin_unlock(&driver_lock); |
381 | return 0; | 377 | return 0; |
382 | } | 378 | } |
383 | |||
384 | EXPORT_SYMBOL_GPL(tpm_release); | 379 | EXPORT_SYMBOL_GPL(tpm_release); |
385 | 380 | ||
386 | ssize_t tpm_write(struct file * file, const char __user * buf, | 381 | ssize_t tpm_write(struct file *file, const char __user *buf, |
387 | size_t size, loff_t * off) | 382 | size_t size, loff_t * off) |
388 | { | 383 | { |
389 | struct tpm_chip *chip = file->private_data; | 384 | struct tpm_chip *chip = file->private_data; |
@@ -419,7 +414,7 @@ ssize_t tpm_write(struct file * file, const char __user * buf, | |||
419 | 414 | ||
420 | EXPORT_SYMBOL_GPL(tpm_write); | 415 | EXPORT_SYMBOL_GPL(tpm_write); |
421 | 416 | ||
422 | ssize_t tpm_read(struct file * file, char __user * buf, | 417 | ssize_t tpm_read(struct file * file, char __user *buf, |
423 | size_t size, loff_t * off) | 418 | size_t size, loff_t * off) |
424 | { | 419 | { |
425 | struct tpm_chip *chip = file->private_data; | 420 | struct tpm_chip *chip = file->private_data; |
@@ -441,7 +436,6 @@ ssize_t tpm_read(struct file * file, char __user * buf, | |||
441 | 436 | ||
442 | return ret_size; | 437 | return ret_size; |
443 | } | 438 | } |
444 | |||
445 | EXPORT_SYMBOL_GPL(tpm_read); | 439 | EXPORT_SYMBOL_GPL(tpm_read); |
446 | 440 | ||
447 | void tpm_remove_hardware(struct device *dev) | 441 | void tpm_remove_hardware(struct device *dev) |
@@ -465,13 +459,13 @@ void tpm_remove_hardware(struct device *dev) | |||
465 | 459 | ||
466 | sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); | 460 | sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); |
467 | 461 | ||
468 | dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); | 462 | dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= |
463 | !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); | ||
469 | 464 | ||
470 | kfree(chip); | 465 | kfree(chip); |
471 | 466 | ||
472 | put_device(dev); | 467 | put_device(dev); |
473 | } | 468 | } |
474 | |||
475 | EXPORT_SYMBOL_GPL(tpm_remove_hardware); | 469 | EXPORT_SYMBOL_GPL(tpm_remove_hardware); |
476 | 470 | ||
477 | static u8 savestate[] = { | 471 | static u8 savestate[] = { |
@@ -493,7 +487,6 @@ int tpm_pm_suspend(struct device *dev, pm_message_t pm_state) | |||
493 | tpm_transmit(chip, savestate, sizeof(savestate)); | 487 | tpm_transmit(chip, savestate, sizeof(savestate)); |
494 | return 0; | 488 | return 0; |
495 | } | 489 | } |
496 | |||
497 | EXPORT_SYMBOL_GPL(tpm_pm_suspend); | 490 | EXPORT_SYMBOL_GPL(tpm_pm_suspend); |
498 | 491 | ||
499 | /* | 492 | /* |
@@ -509,7 +502,6 @@ int tpm_pm_resume(struct device *dev) | |||
509 | 502 | ||
510 | return 0; | 503 | return 0; |
511 | } | 504 | } |
512 | |||
513 | EXPORT_SYMBOL_GPL(tpm_pm_resume); | 505 | EXPORT_SYMBOL_GPL(tpm_pm_resume); |
514 | 506 | ||
515 | /* | 507 | /* |
@@ -519,8 +511,7 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume); | |||
519 | * upon errant exit from this function specific probe function should call | 511 | * upon errant exit from this function specific probe function should call |
520 | * pci_disable_device | 512 | * pci_disable_device |
521 | */ | 513 | */ |
522 | int tpm_register_hardware(struct device *dev, | 514 | int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry) |
523 | struct tpm_vendor_specific *entry) | ||
524 | { | 515 | { |
525 | #define DEVNAME_SIZE 7 | 516 | #define DEVNAME_SIZE 7 |
526 | 517 | ||
@@ -529,12 +520,10 @@ int tpm_register_hardware(struct device *dev, | |||
529 | int i, j; | 520 | int i, j; |
530 | 521 | ||
531 | /* Driver specific per-device data */ | 522 | /* Driver specific per-device data */ |
532 | chip = kmalloc(sizeof(*chip), GFP_KERNEL); | 523 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
533 | if (chip == NULL) | 524 | if (chip == NULL) |
534 | return -ENOMEM; | 525 | return -ENOMEM; |
535 | 526 | ||
536 | memset(chip, 0, sizeof(struct tpm_chip)); | ||
537 | |||
538 | init_MUTEX(&chip->buffer_mutex); | 527 | init_MUTEX(&chip->buffer_mutex); |
539 | init_MUTEX(&chip->tpm_mutex); | 528 | init_MUTEX(&chip->tpm_mutex); |
540 | INIT_LIST_HEAD(&chip->list); | 529 | INIT_LIST_HEAD(&chip->list); |
@@ -558,8 +547,7 @@ int tpm_register_hardware(struct device *dev, | |||
558 | 547 | ||
559 | dev_num_search_complete: | 548 | dev_num_search_complete: |
560 | if (chip->dev_num < 0) { | 549 | if (chip->dev_num < 0) { |
561 | dev_err(dev, | 550 | dev_err(dev, "No available tpm device numbers\n"); |
562 | "No available tpm device numbers\n"); | ||
563 | kfree(chip); | 551 | kfree(chip); |
564 | return -ENODEV; | 552 | return -ENODEV; |
565 | } else if (chip->dev_num == 0) | 553 | } else if (chip->dev_num == 0) |
@@ -597,7 +585,6 @@ dev_num_search_complete: | |||
597 | 585 | ||
598 | return 0; | 586 | return 0; |
599 | } | 587 | } |
600 | |||
601 | EXPORT_SYMBOL_GPL(tpm_register_hardware); | 588 | EXPORT_SYMBOL_GPL(tpm_register_hardware); |
602 | 589 | ||
603 | MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); | 590 | MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); |