* [PATCH] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv()
@ 2021-04-08 11:26 Zhihao Cheng
2021-04-08 16:31 ` Jarkko Sakkinen
0 siblings, 1 reply; 2+ messages in thread
From: Zhihao Cheng @ 2021-04-08 11:26 UTC (permalink / raw)
To: peterhuewe, jarkko
Cc: linux-integrity, linux-kernel, chengzhihao1, yi.zhang, yukuai3
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 <hulkci@huawei.com>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
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..e908da78fbf4 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(&chip->dev, "Buffer too small to receive i2c data\n");
+ rc = -EIO;
goto out_err;
}
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv()
2021-04-08 11:26 [PATCH] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv() Zhihao Cheng
@ 2021-04-08 16:31 ` Jarkko Sakkinen
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2021-04-08 16:31 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: peterhuewe, linux-integrity, linux-kernel, yi.zhang, yukuai3
On Thu, Apr 08, 2021 at 07:26:08PM +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 <hulkci@huawei.com>
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
> 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..e908da78fbf4 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(&chip->dev, "Buffer too small to receive i2c data\n");
> + rc = -EIO;
> goto out_err;
> }
>
> --
> 2.25.4
>
We are using E2BIG in similar situations in a few places:
❯ git grep E2BIG drivers/char/tpm
drivers/char/tpm/tpm-dev-common.c: return -E2BIG;
drivers/char/tpm/tpm-interface.c: return -E2BIG;
drivers/char/tpm/tpm_crb.c: return -E2BIG;
drivers/char/tpm/tpm_i2c_atmel.c: return -E2BIG;
drivers/char/tpm/tpm_i2c_infineon.c: return -E2BIG;
So, I tend to think that also in here it'd be better to use E2BIG.
/Jarkko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-08 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 11:26 [PATCH] char: tpm: fix error return code in tpm_cr50_i2c_tis_recv() Zhihao Cheng
2021-04-08 16:31 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).