Skip to contentSkip to conversation

tpm_crb: initialise priv->cmd_size sooner

PATCH Jarkko Sakkinen 1 participant 1 message Jun 19, 2017 2 messages not in the archive

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · Manuel Lauss

priv->cmd_size is never initialised if the cmd and rsp buffers reside at different addresses. Move initialisation to right after the buffer was mapped.

This bug was introduced by commit aa77ea0e43dc5bb0c1dcc9bad76afa ("tpm/tpm_crb: cache cmd_size register value.").

Please, use a Fixes tag.

Quoted 10 lines
---
 drivers/char/tpm/tpm_crb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_crb.c +0 -0
index b917b9d5f710..17d846d00417 100644

drivers/char/tpm/tpm_crb.c static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, · line 499

Quoted 5 lines
drivers/char/tpm/tpm_crb.c +2 -0
@@ -495,6 +495,8 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
 		goto out;
 	}
 
+	priv->cmd_size = cmd_size;
+

Should be done only if rsp is succesfully mapped.

drivers/char/tpm/tpm_crb.c static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, · line 522

Quoted 12 lines
drivers/char/tpm/tpm_crb.c +0 -2
 	memcpy_fromio(&rsp_pa, &priv->regs_t->ctrl_rsp_pa, 8);
 	rsp_pa = le64_to_cpu(rsp_pa);
 	rsp_size = crb_fixup_cmd_size(dev, &io_res, rsp_pa,
@@ -515,8 +517,6 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
 		goto out;
 	}
 
-	priv->cmd_size = cmd_size;
-
 	priv->rsp = priv->cmd;
 
 out:

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot