Skip to contentSkip to conversation

tpm: Remove illict WARN's from tpm2-sessions.c

PATCH New Jarkko Sakkinen 1 participant 1 message May 29, 2024

Subsystems (5)
lore
Share & tools
lore

Jarkko Sakkinen

author maintainer
#0 lore raw

PATCH 1/1 tpm: Remove illict WARN's from tpm2-sessions.c

Sprinkling all over the place is just plain wrong so drop all of them before the TPM bus encryption feature hits a release.

Fixes 1085b8276bb4 ("tpm: Add the rest of the session HMAC API")

---
I have had to literally fight for so many other cosmetic things such as
https://lore.kernel.org/linux-integrity/[email protected]/T/#u
so that I must have missed this.

If I contribute to any subsystem, I just plain do all that is asked, no questions asked. Only reason I left a review unaddressed is when I see some intersection with the architecture.

And lastly, not introducing new WARN's should be dead obvious, unless per-WARN explicitly reasoned in the commit message near to the level that it could be proven at court. Unless this care, I will simply not review patch with something like this embedded.

---
 drivers/char/tpm/tpm2-sessions.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm2-sessions.c +7 -5
index 907ac9956a78..371cf28a2b6a 100644
@@ -394,7 +394,7 @@ void tpm_buf_append_hmac_session(struct tpm_chip *chip, struct tpm_buf *buf,
 		/* we're not the first session */
 		len = get_unaligned_be32(&buf->data[auth->session]);
 		if (4 + len + auth->session != tpm_buf_length(buf)) {
-			WARN(1, "session length mismatch, cannot append");
+			pr_warn("tpm: session length mismatch, cannot append");
 			return;
 		}
 
@@ -644,8 +644,10 @@ void tpm_buf_append_name(struct tpm_chip *chip, struct tpm_buf *buf,
 		dev_err(&chip->dev, "TPM: too many handles\n");
 		return;
 	}
-	WARN(auth->session != tpm_buf_length(buf),
-	     "name added in wrong place\n");
+	if (auth->session != tpm_buf_length(buf)) {
+		pr_warn("tpm: name added in wrong place\n");
+		return;
+	}
 	tpm_buf_append_u32(buf, handle);
 	auth->session += 4;
 
@@ -706,8 +708,8 @@ int tpm_buf_check_hmac_response(struct tpm_chip *chip, struct tpm_buf *buf,
 	int parm_len, len, i, handles;
 
 	if (auth->session >= TPM_HEADER_SIZE) {
-		WARN(1, "tpm session not filled correctly\n");
-		goto out;
+		pr_warn("tpm session not filled correctly\n");
+		return;
 	}
 
 	if (rc != 0)
Signature · 1 line
2.45.1