diff options
-rw-r--r-- | drivers/char/tpm/tpm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 1fe979335835..9ca5c021d0b6 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -1105,6 +1105,7 @@ ssize_t tpm_read(struct file *file, char __user *buf, | |||
1105 | { | 1105 | { |
1106 | struct tpm_chip *chip = file->private_data; | 1106 | struct tpm_chip *chip = file->private_data; |
1107 | ssize_t ret_size; | 1107 | ssize_t ret_size; |
1108 | int rc; | ||
1108 | 1109 | ||
1109 | del_singleshot_timer_sync(&chip->user_read_timer); | 1110 | del_singleshot_timer_sync(&chip->user_read_timer); |
1110 | flush_work_sync(&chip->work); | 1111 | flush_work_sync(&chip->work); |
@@ -1115,8 +1116,11 @@ ssize_t tpm_read(struct file *file, char __user *buf, | |||
1115 | ret_size = size; | 1116 | ret_size = size; |
1116 | 1117 | ||
1117 | mutex_lock(&chip->buffer_mutex); | 1118 | mutex_lock(&chip->buffer_mutex); |
1118 | 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) | ||
1119 | ret_size = -EFAULT; | 1122 | ret_size = -EFAULT; |
1123 | |||
1120 | mutex_unlock(&chip->buffer_mutex); | 1124 | mutex_unlock(&chip->buffer_mutex); |
1121 | } | 1125 | } |
1122 | 1126 | ||