2020-04-15 21:26:34

by Tianjia Zhang

[permalink] [raw]
Subject: [PATCH] tpm: fix wrong return value in tpm_pcr_extend

For the algorithm that does not match the bank, a positive
value EINVAL is returned here. I think this is a typo error.
It is necessary to return an error value.

Signed-off-by: Tianjia Zhang <[email protected]>
---
drivers/char/tpm/tpm-interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index a438b1206fcb..1621ce818705 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -323,7 +323,7 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,

for (i = 0; i < chip->nr_allocated_banks; i++) {
if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
- rc = EINVAL;
+ rc = -EINVAL;
goto out;
}
}
--
2.17.1


2020-04-15 21:27:50

by Roberto Sassu

[permalink] [raw]
Subject: RE: [PATCH] tpm: fix wrong return value in tpm_pcr_extend

> -----Original Message-----
> From: [email protected] [mailto:linux-integrity-
> [email protected]] On Behalf Of Tianjia Zhang
> Sent: Tuesday, April 14, 2020 1:42 PM
> To: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected];
> [email protected]
> Subject: [PATCH] tpm: fix wrong return value in tpm_pcr_extend
>
> For the algorithm that does not match the bank, a positive
> value EINVAL is returned here. I think this is a typo error.
> It is necessary to return an error value.

Yes, thanks.

Reviewed-by: Roberto Sassu <[email protected]>

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli


> Signed-off-by: Tianjia Zhang <[email protected]>
> ---
> drivers/char/tpm/tpm-interface.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-
> interface.c
> index a438b1206fcb..1621ce818705 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -323,7 +323,7 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32
> pcr_idx,
>
> for (i = 0; i < chip->nr_allocated_banks; i++) {
> if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
> - rc = EINVAL;
> + rc = -EINVAL;
> goto out;
> }
> }
> --
> 2.17.1

2020-04-15 21:52:09

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH] tpm: fix wrong return value in tpm_pcr_extend

On Tue, Apr 14, 2020 at 11:55:43AM +0000, Roberto Sassu wrote:
> > -----Original Message-----
> > From: [email protected] [mailto:linux-integrity-
> > [email protected]] On Behalf Of Tianjia Zhang
> > Sent: Tuesday, April 14, 2020 1:42 PM
> > To: [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected]
> > Cc: [email protected]; [email protected];
> > [email protected]
> > Subject: [PATCH] tpm: fix wrong return value in tpm_pcr_extend
> >
> > For the algorithm that does not match the bank, a positive
> > value EINVAL is returned here. I think this is a typo error.
> > It is necessary to return an error value.
>
> Yes, thanks.
>
> Reviewed-by: Roberto Sassu <[email protected]>

Happen to have the commit ID at hand for fixes?

Thanks.

/Jarkko

2020-04-15 21:54:54

by Jerry Snitselaar

[permalink] [raw]
Subject: Re: [PATCH] tpm: fix wrong return value in tpm_pcr_extend

On Tue Apr 14 20, Tianjia Zhang wrote:
>For the algorithm that does not match the bank, a positive
>value EINVAL is returned here. I think this is a typo error.
>It is necessary to return an error value.
>
>Signed-off-by: Tianjia Zhang <[email protected]>

Reviewed-by: Jerry Snitselaar <[email protected]>

>---
> drivers/char/tpm/tpm-interface.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
>index a438b1206fcb..1621ce818705 100644
>--- a/drivers/char/tpm/tpm-interface.c
>+++ b/drivers/char/tpm/tpm-interface.c
>@@ -323,7 +323,7 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
>
> for (i = 0; i < chip->nr_allocated_banks; i++) {
> if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
>- rc = EINVAL;
>+ rc = -EINVAL;
> goto out;
> }
> }
>--
>2.17.1
>