On Fri, 2021-01-29 at 01:56 +0200, jarkko@kernel.org wrote:
From: Jarkko Sakkinen jarkko@kernel.org
When tpm_get_random() was introduced, it defined the following API for the return value:
- A positive value tells how many bytes of random data was generated.
- A negative value on error.
However, in the call sites the API was used incorrectly, i.e. as it would only return negative values and otherwise zero. Returning he positive read counts to the user space does not make any possible sense.
Fix this by returning -EIO when tpm_get_random() returns a positive value.
Fixes: 41ab999c80f1 ("tpm: Move tpm_get_random api into the TPM device driver") Cc: stable@vger.kernel.org Cc: Mimi Zohar zohar@linux.ibm.com Cc: "James E.J. Bottomley" James.Bottomley@HansenPartnership.com Cc: David Howells dhowells@redhat.com Cc: Kent Yoder key@linux.vnet.ibm.com Signed-off-by: Jarkko Sakkinen jarkko@kernel.org
thanks,
Reviewed-by: Mimi Zohar zohar@linux.ibm.com