diff mbox

[v3] tpm: Return the actual size when receiving an unsupported command

Message ID 20180620143823.14718-1-Ricardo.Schwarzmeier@infineon.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ricardo Schwarzmeier June 20, 2018, 2:38 p.m. UTC
The userpace expects to read the number of bytes stated in the header.
Returning the size of the buffer instead would be unexpected.

Fixes: 095531f891e6 ("tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented")

Signed-off-by: Ricardo Schwarzmeier <Ricardo.Schwarzmeier@infineon.com>
---
Changes since v2:
 * Made commit message more clear
 * Avoided endianness problems
---
 drivers/char/tpm/tpm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jarkko Sakkinen June 21, 2018, 4:49 p.m. UTC | #1
On Wed, Jun 20, 2018 at 04:38:23PM +0200, Ricardo Schwarzmeier wrote:
> The userpace expects to read the number of bytes stated in the header.
> Returning the size of the buffer instead would be unexpected.
> 
> Fixes: 095531f891e6 ("tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented")
> 

No empty line here.

> Signed-off-by: Ricardo Schwarzmeier <Ricardo.Schwarzmeier@infineon.com>
> ---
> Changes since v2:
>  * Made commit message more clear
>  * Avoided endianness problems
> ---

The change log hould be here in order not to be included as part of
the commit message.

/Jarkko
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index e32f6e85dc6d..7f2e2d54894d 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -423,7 +423,7 @@  static ssize_t tpm_try_transmit(struct tpm_chip *chip,
 		header->tag = cpu_to_be16(TPM2_ST_NO_SESSIONS);
 		header->return_code = cpu_to_be32(TPM2_RC_COMMAND_CODE |
 						  TSS2_RESMGR_TPM_RC_LAYER);
-		return bufsiz;
+		return sizeof(*header);
 	}
 
 	if (bufsiz > TPM_BUFSIZE)