Skip to contentSkip to conversation

tpm: tpm_try_transmit() ignore value of go_to_idle()

PATCH In review Tomas Winkler 3 participants 5 messages Oct 15, 2018 – Oct 17, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: tpm_try_transmit() ignore value of go_to_idle()

Ignore the return value of go_to_idle() in tpm_try_transmit(). Once it may shadow the return value of actual tpm operation, second the consequent command will fail as well and the error will be caought anyway.
Last fix wrong goto, that jumped back instead of forward.

Fixes 627448e85c76 ("tpm: separate cmd_ready/go_idle from runtime_pm")
---
 drivers/char/tpm/tpm-interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -3
index 129f640424b7..f69c711bf74a 100644
@@ -547,9 +547,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
 		dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
 
 out:
-	rc = tpm_go_idle(chip, flags);
-	if (rc)
-		goto out;
+	(void)tpm_go_idle(chip, flags);
 
 	if (need_locality)
 		tpm_relinquish_locality(chip, flags);
Signature · 1 line
2.14.4
#1 lore raw
Quoted 15 lines · Tomas Winkler

Ignore the return value of go_to_idle() in tpm_try_transmit(). Once it may shadow the return value of actual tpm operation, second the consequent command will fail as well and the error will be caought anyway.
Last fix wrong goto, that jumped back instead of forward.

Fixes 627448e85c76 ("tpm: separate cmd_ready/go_idle from runtime_pm")
 drivers/char/tpm/tpm-interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 129f640424b7..f69c711bf74a 100644
+++ b/drivers/char/tpm/tpm-interface.c

drivers/char/tpm/tpm-interface.c static ssize_t tpm_try_transmit(struct tpm_chip *chip, · line 550

Quoted 7 lines
drivers/char/tpm/tpm-interface.c +1 -3
@@ -547,9 +547,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
 		dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
 
 out:
-	rc = tpm_go_idle(chip, flags);
-	if (rc)
-		goto out;
+	(void)tpm_go_idle(chip, flags);

We don't really use this style in the kernel, AFAIK.

Jason

#2 lore raw
Quoted 24 lines · Tomas Winkler

drivers/char/tpm/tpm-interface.c static ssize_t tpm_try_transmit(struct tpm_chip

Quoted 17 lines

Ignore the return value of go_to_idle() in tpm_try_transmit(). Once it may shadow the return value of actual tpm operation, second the consequent command will fail as well and the error will be caought anyway.
Last fix wrong goto, that jumped back instead of forward.

Fixes 627448e85c76 ("tpm: separate cmd_ready/go_idle from

runtime_pm")

drivers/char/tpm/tpm-interface.c | 4 +---

 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 129f640424b7..f69c711bf74a 100644
+++ b/drivers/char/tpm/tpm-interface.c
@@ -547,9 +547,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip

*chip,

Quoted 2 lines
drivers/char/tpm/tpm-interface.c +0 -0
 		dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
 
Quoted 7 lines

drivers/char/tpm/tpm-interface.c static ssize_t tpm_try_transmit(struct tpm_chip *chip, · line 550

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -3
 out:
-	rc = tpm_go_idle(chip, flags);
-	if (rc)
-		goto out;
+	(void)tpm_go_idle(chip, flags);

We don't really use this style in the kernel, AFAIK.

Right, there are no many of those; just wanted to emphasize that return value is ignored. I can drop (void).

Thanks
Tomas

Reviewed-by on v1 1/1
#3 lore raw
In reply to Tomas Winkler
Quoted 25 lines · Tomas Winkler

Ignore the return value of go_to_idle() in tpm_try_transmit(). Once it may shadow the return value of actual tpm operation, second the consequent command will fail as well and the error will be caought anyway.
Last fix wrong goto, that jumped back instead of forward.

Fixes 627448e85c76 ("tpm: separate cmd_ready/go_idle from runtime_pm")

---
drivers/char/tpm/tpm-interface.c | 4 +---

1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +0 -0
index 129f640424b7..f69c711bf74a 100644
@@ -547,9 +547,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
 		dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
 

out:

drivers/char/tpm/tpm-interface.c +1 -3
-	rc = tpm_go_idle(chip, flags);
-	if (rc)
-		goto out;
+	(void)tpm_go_idle(chip, flags);
Quoted 6 lines
	if (need_locality)
		tpm_relinquish_locality(chip, flags);
Signature · 1 line
2.14.4

LGTM. Should be probably Cc'd to stable (can add).

/Jarkko

#4 lore raw
Quoted 51 lines

-----Original Message-----
From: Jarkko Sakkinen [mailto:[email protected]]
Sent: Thursday, October 18, 2018 02:01
To: Winkler, Tomas <[email protected]>
Cc: Jarkko Sakkinen <[email protected]>; Jason Gunthorpe <[email protected]>; Nayna Jain <[email protected]>; Usyskin, Alexander <[email protected]>; Struk, Tadeusz <[email protected]>; [email protected]; linux-security- [email protected]; [email protected]
Subject: Re: [PATCH] tpm: tpm_try_transmit() ignore value of go_to_idle()

drivers/char/tpm/tpm-interface.c static ssize_t tpm_try_transmit(struct tpm_chip

Quoted 19 lines · Tomas Winkler

Ignore the return value of go_to_idle() in tpm_try_transmit(). Once it may shadow the return value of actual tpm operation, second the consequent command will fail as well and the error will be caought anyway.
Last fix wrong goto, that jumped back instead of forward.

Fixes 627448e85c76 ("tpm: separate cmd_ready/go_idle from

runtime_pm")

---
drivers/char/tpm/tpm-interface.c | 4 +---

1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +0 -0
index 129f640424b7..f69c711bf74a 100644
@@ -547,9 +547,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip

*chip,

Quoted 8 lines
drivers/char/tpm/tpm-interface.c +0 -0
 		dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc);
 

out:

drivers/char/tpm/tpm-interface.c +1 -3
-	rc = tpm_go_idle(chip, flags);
-	if (rc)
-		goto out;
+	(void)tpm_go_idle(chip, flags);
Quoted 6 lines
	if (need_locality)
		tpm_relinquish_locality(chip, flags);

--
2.14.4

LGTM. Should be probably Cc'd to stable (can add).

Quoted 1 line

I've posted another one, there are more issues in the flow.