diff mbox series

[v3,05/16] tpm: print tpm2_commit_space() error inside tpm2_commit_space()

Message ID 20181105014552.20262-6-jarkko.sakkinen@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Remove nested TPM operations | expand

Commit Message

Jarkko Sakkinen Nov. 5, 2018, 1:45 a.m. UTC
The error logging for tpm2_commit_space() is in a wrong place. This
commit moves it inside that function.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm2-space.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Stefan Berger Nov. 5, 2018, 10:04 p.m. UTC | #1
On 11/4/18 8:45 PM, Jarkko Sakkinen wrote:
> The error logging for tpm2_commit_space() is in a wrong place. This
> commit moves it inside that function.
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
>   drivers/char/tpm/tpm2-space.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> index d53c882268ff..3d5f9577e5de 100644
> --- a/drivers/char/tpm/tpm2-space.c
> +++ b/drivers/char/tpm/tpm2-space.c
> @@ -501,19 +501,19 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
>   	rc = tpm2_map_response_header(chip, cc, buf, *bufsiz);
>   	if (rc) {
>   		tpm2_flush_space(chip);
> -		return rc;
> +		goto out;
>   	}
>
>   	rc = tpm2_map_response_body(chip, cc, buf, *bufsiz);
>   	if (rc) {
>   		tpm2_flush_space(chip);
> -		return rc;
> +		goto out;
>   	}
>
>   	rc = tpm2_save_space(chip);
>   	if (rc) {
>   		tpm2_flush_space(chip);
> -		return rc;
> +		goto out;
>   	}
>
>   	*bufsiz = be32_to_cpu(header->length);
> @@ -526,4 +526,7 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
>   	memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE);
>
>   	return 0;
> +out:
> +	dev_err(&chip->dev, "%s: error %d\n", __func__, rc);
> +	return rc;
>   }


This is in tpm-interface.c:

     rc = tpm2_commit_space(chip, space, ordinal, buf, &len);
     if (rc)
         dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);

I suppose you will remove if(rc) ... ?
Jarkko Sakkinen Nov. 6, 2018, 5:58 a.m. UTC | #2
On Mon, Nov 05, 2018 at 05:04:46PM -0500, Stefan Berger wrote:
> On 11/4/18 8:45 PM, Jarkko Sakkinen wrote:
> > The error logging for tpm2_commit_space() is in a wrong place. This
> > commit moves it inside that function.
> > 
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> >   drivers/char/tpm/tpm2-space.c | 9 ++++++---
> >   1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> > index d53c882268ff..3d5f9577e5de 100644
> > --- a/drivers/char/tpm/tpm2-space.c
> > +++ b/drivers/char/tpm/tpm2-space.c
> > @@ -501,19 +501,19 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
> >   	rc = tpm2_map_response_header(chip, cc, buf, *bufsiz);
> >   	if (rc) {
> >   		tpm2_flush_space(chip);
> > -		return rc;
> > +		goto out;
> >   	}
> > 
> >   	rc = tpm2_map_response_body(chip, cc, buf, *bufsiz);
> >   	if (rc) {
> >   		tpm2_flush_space(chip);
> > -		return rc;
> > +		goto out;
> >   	}
> > 
> >   	rc = tpm2_save_space(chip);
> >   	if (rc) {
> >   		tpm2_flush_space(chip);
> > -		return rc;
> > +		goto out;
> >   	}
> > 
> >   	*bufsiz = be32_to_cpu(header->length);
> > @@ -526,4 +526,7 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
> >   	memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE);
> > 
> >   	return 0;
> > +out:
> > +	dev_err(&chip->dev, "%s: error %d\n", __func__, rc);
> > +	return rc;
> >   }
> 
> 
> This is in tpm-interface.c:
> 
>     rc = tpm2_commit_space(chip, space, ordinal, buf, &len);
>     if (rc)
>         dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
> 
> I suppose you will remove if(rc) ... ?

That removal must have gone at some point when rebasing fixups.
Thanks.

/Jarkko
diff mbox series

Patch

diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
index d53c882268ff..3d5f9577e5de 100644
--- a/drivers/char/tpm/tpm2-space.c
+++ b/drivers/char/tpm/tpm2-space.c
@@ -501,19 +501,19 @@  int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
 	rc = tpm2_map_response_header(chip, cc, buf, *bufsiz);
 	if (rc) {
 		tpm2_flush_space(chip);
-		return rc;
+		goto out;
 	}
 
 	rc = tpm2_map_response_body(chip, cc, buf, *bufsiz);
 	if (rc) {
 		tpm2_flush_space(chip);
-		return rc;
+		goto out;
 	}
 
 	rc = tpm2_save_space(chip);
 	if (rc) {
 		tpm2_flush_space(chip);
-		return rc;
+		goto out;
 	}
 
 	*bufsiz = be32_to_cpu(header->length);
@@ -526,4 +526,7 @@  int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
 	memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE);
 
 	return 0;
+out:
+	dev_err(&chip->dev, "%s: error %d\n", __func__, rc);
+	return rc;
 }