Skip to contentSkip to conversation

tpm: Fix alignment of buf->handles

PATCH New Jarkko Sakkinen 1 participant 1 message Jul 16, 2024

Subsystems (5)
lore
Share & tools
lore

Jarkko Sakkinen

author maintainer
#0 lore raw

PATCH 1/1 tpm: Fix alignment of buf->handles

tpm_buf_append_name() has the following snippet in the beginning:

	if (!tpm2_chip_auth(chip)) {
		tpm_buf_append_u32(buf, handle);
		/* count the number of handles in the upper bits of flags */
		buf->handles++;
		return;
	}

The claim in the comment is wrong, and the comment is in the wrong place as it should not be anyway a concern of the "call site". So in essence it is lying about the code.

Fix the alignment to be aligned with the claim in the comment and remove the comment.

Cc [email protected] # v6.10+
Fixes 699e3efd6c64 ("tpm: Add HMAC session start and end functions")
---
 drivers/char/tpm/tpm2-sessions.c | 1 -
 include/linux/tpm.h              | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm2-sessions.c +0 -1
index d3521aadd43e..02fc5d4ff535 100644
@@ -238,7 +238,6 @@ void tpm_buf_append_name(struct tpm_chip *chip, struct tpm_buf *buf,
 
 	if (!tpm2_chip_auth(chip)) {
 		tpm_buf_append_u32(buf, handle);
-		/* count the number of handles in the upper bits of flags */
 		buf->handles++;
 		return;
 	}
include/linux/tpm.h +2 -2
index e93ee8d936a9..4b55298520b5 100644
@@ -374,10 +374,10 @@ enum tpm_buf_flags {
  * A string buffer type for constructing TPM commands.
  */
 struct tpm_buf {
-	u32 flags;
+	u16 flags;
+	u16 handles;
 	u32 length;
 	u8 *data;
-	u8 handles;
 };
 
 enum tpm2_object_attributes {
Signature · 1 line
2.45.2