Re: [PATCH v2] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv()

2021-04-08 Thread Jarkko Sakkinen
On Fri, Apr 09, 2021 at 09:12:01AM +0800, Zhihao Cheng wrote:
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Fixes: 3a253caaad11 ("char: tpm: add i2c driver for cr50")
> Reported-by: Hulk Robot 
> Signed-off-by: Zhihao Cheng 

Reviewed-by: Jarkko Sakkinen 

> ---
>  drivers/char/tpm/tpm_tis_i2c_cr50.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/char/tpm/tpm_tis_i2c_cr50.c 
> b/drivers/char/tpm/tpm_tis_i2c_cr50.c
> index ec9a65e7887d..f19c227d20f4 100644
> --- a/drivers/char/tpm/tpm_tis_i2c_cr50.c
> +++ b/drivers/char/tpm/tpm_tis_i2c_cr50.c
> @@ -483,6 +483,7 @@ static int tpm_cr50_i2c_tis_recv(struct tpm_chip *chip, 
> u8 *buf, size_t buf_len)
>   expected = be32_to_cpup((__be32 *)(buf + 2));
>   if (expected > buf_len) {
>   dev_err(>dev, "Buffer too small to receive i2c data\n");
> + rc = -E2BIG;
>   goto out_err;
>   }
>  
> -- 
> 2.25.4
> 
> 

/Jarkko


[PATCH v2] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv()

2021-04-08 Thread Zhihao Cheng
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 3a253caaad11 ("char: tpm: add i2c driver for cr50")
Reported-by: Hulk Robot 
Signed-off-by: Zhihao Cheng 
---
 drivers/char/tpm/tpm_tis_i2c_cr50.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/tpm/tpm_tis_i2c_cr50.c 
b/drivers/char/tpm/tpm_tis_i2c_cr50.c
index ec9a65e7887d..f19c227d20f4 100644
--- a/drivers/char/tpm/tpm_tis_i2c_cr50.c
+++ b/drivers/char/tpm/tpm_tis_i2c_cr50.c
@@ -483,6 +483,7 @@ static int tpm_cr50_i2c_tis_recv(struct tpm_chip *chip, u8 
*buf, size_t buf_len)
expected = be32_to_cpup((__be32 *)(buf + 2));
if (expected > buf_len) {
dev_err(>dev, "Buffer too small to receive i2c data\n");
+   rc = -E2BIG;
goto out_err;
}
 
-- 
2.25.4