Skip to content

Commit 0082102

Browse files
tstrukflorpor
authored andcommitted
tpm: Handle negative priv->response_len in tpm_common_read()
commit a430e67 upstream. The priv->response_length can hold the size of an response or an negative error code, and the tpm_common_read() needs to handle both cases correctly. Changed the type of response_length to signed and accounted for negative value in tpm_common_read(). Cc: stable@vger.kernel.org Fixes: d23d124 ("tpm: fix invalid locking in NONBLOCKING mode") Reported-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2f84e15 commit 0082102

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: drivers/char/tpm/tpm-dev-common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
130130
priv->response_read = true;
131131

132132
ret_size = min_t(ssize_t, size, priv->response_length);
133-
if (!ret_size) {
133+
if (ret_size <= 0) {
134134
priv->response_length = 0;
135135
goto out;
136136
}

Diff for: drivers/char/tpm/tpm-dev.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct file_priv {
1414
struct work_struct timeout_work;
1515
struct work_struct async_work;
1616
wait_queue_head_t async_wait;
17-
size_t response_length;
17+
ssize_t response_length;
1818
bool response_read;
1919
bool command_enqueued;
2020

0 commit comments

Comments
 (0)