diff options
| -rw-r--r-- | drivers/char/tpm/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/char/tpm/tpm.c | 9 | ||||
| -rw-r--r-- | drivers/char/tpm/tpm_nsc.c | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index f6595aba4f0f..fa567f1158c2 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
| @@ -43,6 +43,7 @@ config TCG_NSC | |||
| 43 | 43 | ||
| 44 | config TCG_ATMEL | 44 | config TCG_ATMEL |
| 45 | tristate "Atmel TPM Interface" | 45 | tristate "Atmel TPM Interface" |
| 46 | depends on PPC64 || HAS_IOPORT | ||
| 46 | ---help--- | 47 | ---help--- |
| 47 | If you have a TPM security chip from Atmel say Yes and it | 48 | If you have a TPM security chip from Atmel say Yes and it |
| 48 | will be accessible from within Linux. To compile this driver | 49 | will be accessible from within Linux. To compile this driver |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index caf8012ef47c..9ca5c021d0b6 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
| @@ -383,6 +383,9 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
| 383 | u32 count, ordinal; | 383 | u32 count, ordinal; |
| 384 | unsigned long stop; | 384 | unsigned long stop; |
| 385 | 385 | ||
| 386 | if (bufsiz > TPM_BUFSIZE) | ||
| 387 | bufsiz = TPM_BUFSIZE; | ||
| 388 | |||
| 386 | count = be32_to_cpu(*((__be32 *) (buf + 2))); | 389 | count = be32_to_cpu(*((__be32 *) (buf + 2))); |
| 387 | ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); | 390 | ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); |
| 388 | if (count == 0) | 391 | if (count == 0) |
| @@ -1102,6 +1105,7 @@ ssize_t tpm_read(struct file *file, char __user *buf, | |||
| 1102 | { | 1105 | { |
| 1103 | struct tpm_chip *chip = file->private_data; | 1106 | struct tpm_chip *chip = file->private_data; |
| 1104 | ssize_t ret_size; | 1107 | ssize_t ret_size; |
| 1108 | int rc; | ||
| 1105 | 1109 | ||
| 1106 | del_singleshot_timer_sync(&chip->user_read_timer); | 1110 | del_singleshot_timer_sync(&chip->user_read_timer); |
| 1107 | flush_work_sync(&chip->work); | 1111 | flush_work_sync(&chip->work); |
| @@ -1112,8 +1116,11 @@ ssize_t tpm_read(struct file *file, char __user *buf, | |||
| 1112 | ret_size = size; | 1116 | ret_size = size; |
| 1113 | 1117 | ||
| 1114 | mutex_lock(&chip->buffer_mutex); | 1118 | mutex_lock(&chip->buffer_mutex); |
| 1115 | if (copy_to_user(buf, chip->data_buffer, ret_size)) | 1119 | rc = copy_to_user(buf, chip->data_buffer, ret_size); |
| 1120 | memset(chip->data_buffer, 0, ret_size); | ||
| 1121 | if (rc) | ||
| 1116 | ret_size = -EFAULT; | 1122 | ret_size = -EFAULT; |
| 1123 | |||
| 1117 | mutex_unlock(&chip->buffer_mutex); | 1124 | mutex_unlock(&chip->buffer_mutex); |
| 1118 | } | 1125 | } |
| 1119 | 1126 | ||
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 82facc9104c7..4d2464871ada 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
| @@ -396,8 +396,6 @@ static void __exit cleanup_nsc(void) | |||
| 396 | if (pdev) { | 396 | if (pdev) { |
| 397 | tpm_nsc_remove(&pdev->dev); | 397 | tpm_nsc_remove(&pdev->dev); |
| 398 | platform_device_unregister(pdev); | 398 | platform_device_unregister(pdev); |
| 399 | kfree(pdev); | ||
| 400 | pdev = NULL; | ||
| 401 | } | 399 | } |
| 402 | 400 | ||
| 403 | platform_driver_unregister(&nsc_drv); | 401 | platform_driver_unregister(&nsc_drv); |
