* [PATCH] tpm: Add missing check in tpm_inf_recv
@ 2021-02-28 9:32 Dinghao Liu
2021-03-01 9:48 ` Jarkko Sakkinen
0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2021-02-28 9:32 UTC (permalink / raw)
To: dinghao.liu, kjlu
Cc: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, linux-integrity,
linux-kernel
The use of wait() in tpm_inf_recv() is almost the same. It's odd that
we only check the return value and terminate execution flow of one call.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/char/tpm/tpm_infineon.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 9c924a1440a9..abe00f45aa45 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -263,7 +263,9 @@ static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count)
size = ((buf[2] << 8) | buf[3]);
for (i = 0; i < size; i++) {
- wait(chip, STAT_RDA);
+ ret = wait(chip, STAT_RDA);
+ if (ret)
+ return -EIO;
buf[i] = tpm_data_in(RDFIFO);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tpm: Add missing check in tpm_inf_recv
2021-02-28 9:32 [PATCH] tpm: Add missing check in tpm_inf_recv Dinghao Liu
@ 2021-03-01 9:48 ` Jarkko Sakkinen
2021-03-01 11:30 ` dinghao.liu
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2021-03-01 9:48 UTC (permalink / raw)
To: Dinghao Liu
Cc: kjlu, Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel
On Sun, Feb 28, 2021 at 05:32:30PM +0800, Dinghao Liu wrote:
> The use of wait() in tpm_inf_recv() is almost the same. It's odd that
> we only check the return value and terminate execution flow of one call.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Is the unchecked return value of wait() the problem? I don't see the
function even mentioned in the description.
/Jarkko
> ---
> drivers/char/tpm/tpm_infineon.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
> index 9c924a1440a9..abe00f45aa45 100644
> --- a/drivers/char/tpm/tpm_infineon.c
> +++ b/drivers/char/tpm/tpm_infineon.c
> @@ -263,7 +263,9 @@ static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count)
> size = ((buf[2] << 8) | buf[3]);
>
> for (i = 0; i < size; i++) {
> - wait(chip, STAT_RDA);
> + ret = wait(chip, STAT_RDA);
> + if (ret)
> + return -EIO;
> buf[i] = tpm_data_in(RDFIFO);
> }
>
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Re: [PATCH] tpm: Add missing check in tpm_inf_recv
2021-03-01 9:48 ` Jarkko Sakkinen
@ 2021-03-01 11:30 ` dinghao.liu
0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2021-03-01 11:30 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: kjlu, Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel
"Jarkko Sakkinen" <jarkko@kernel.org>写道:
> On Sun, Feb 28, 2021 at 05:32:30PM +0800, Dinghao Liu wrote:
> > The use of wait() in tpm_inf_recv() is almost the same. It's odd that
> > we only check the return value and terminate execution flow of one call.
> >
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
>
> Is the unchecked return value of wait() the problem? I don't see the
> function even mentioned in the description.
>
Yes. This issue is reported by my static analysis tool. I think we
should treat wait() equally in this function (check the return value
and return an error code on failure).
Regards,
Dinghao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-01 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 9:32 [PATCH] tpm: Add missing check in tpm_inf_recv Dinghao Liu
2021-03-01 9:48 ` Jarkko Sakkinen
2021-03-01 11:30 ` dinghao.liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.