summaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-11-03 09:15:07 -0400
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2019-02-13 02:48:12 -0500
commit5faafbab77e37290daa023ba2002e0d611682397 (patch)
treeb66dd634a13838e846b716f08132f34f2a02dc5a /drivers/char/tpm
parent29b47ce987591254602cd7b69acd0eecc62f0a70 (diff)
tpm: remove @space from tpm_transmit()
Remove @space from tpm_transmit() API` in order to completely remove the bound between low-level transmission functionality and TPM spaces. The only real dependency existing is the amount of data saved before trying to send a command to the TPM. It doesn't really matter if we save always a bit more than needed so this commit changes the amount saved always to be the size of the TPM header and three handles. Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com> Tested-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm-dev-common.c2
-rw-r--r--drivers/char/tpm/tpm-interface.c25
-rw-r--r--drivers/char/tpm/tpm-sysfs.c5
-rw-r--r--drivers/char/tpm/tpm.h10
-rw-r--r--drivers/char/tpm/tpm1-cmd.c16
-rw-r--r--drivers/char/tpm/tpm2-cmd.c30
-rw-r--r--drivers/char/tpm/tpm2-space.c6
-rw-r--r--drivers/char/tpm/tpm_vtpm_proxy.c2
8 files changed, 43 insertions, 53 deletions
diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index 327d1dca92c8..95fe652b34ff 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -48,7 +48,7 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,
48 if (ret) 48 if (ret)
49 goto out_lock; 49 goto out_lock;
50 50
51 len = tpm_transmit(chip, space, buf, bufsiz, TPM_TRANSMIT_UNLOCKED); 51 len = tpm_transmit(chip, buf, bufsiz, TPM_TRANSMIT_UNLOCKED);
52 if (len < 0) 52 if (len < 0)
53 ret = len; 53 ret = len;
54 54
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 138c9c165a9d..5acbef8cf2ce 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -120,8 +120,8 @@ static int tpm_go_idle(struct tpm_chip *chip, unsigned int flags)
120 return chip->ops->go_idle(chip); 120 return chip->ops->go_idle(chip);
121} 121}
122 122
123static ssize_t tpm_try_transmit(struct tpm_chip *chip, struct tpm_space *space, 123static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz,
124 void *buf, size_t bufsiz, unsigned int flags) 124 unsigned int flags)
125{ 125{
126 struct tpm_header *header = buf; 126 struct tpm_header *header = buf;
127 int rc; 127 int rc;
@@ -199,7 +199,6 @@ out_recv:
199/** 199/**
200 * tpm_transmit - Internal kernel interface to transmit TPM commands. 200 * tpm_transmit - Internal kernel interface to transmit TPM commands.
201 * @chip: a TPM chip to use 201 * @chip: a TPM chip to use
202 * @space: a TPM space
203 * @buf: a TPM command buffer 202 * @buf: a TPM command buffer
204 * @bufsiz: length of the TPM command buffer 203 * @bufsiz: length of the TPM command buffer
205 * @flags: TPM transmit flags 204 * @flags: TPM transmit flags
@@ -215,8 +214,8 @@ out_recv:
215 * * The response length - OK 214 * * The response length - OK
216 * * -errno - A system error 215 * * -errno - A system error
217 */ 216 */
218ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, 217ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
219 u8 *buf, size_t bufsiz, unsigned int flags) 218 unsigned int flags)
220{ 219{
221 struct tpm_header *header = (struct tpm_header *)buf; 220 struct tpm_header *header = (struct tpm_header *)buf;
222 /* space for header and handles */ 221 /* space for header and handles */
@@ -225,8 +224,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
225 bool has_locality = false; 224 bool has_locality = false;
226 u32 rc = 0; 225 u32 rc = 0;
227 ssize_t ret; 226 ssize_t ret;
228 const size_t save_size = min(space ? sizeof(save) : TPM_HEADER_SIZE, 227 const size_t save_size = min(sizeof(save), bufsiz);
229 bufsiz);
230 /* the command code is where the return code will be */ 228 /* the command code is where the return code will be */
231 u32 cc = be32_to_cpu(header->return_code); 229 u32 cc = be32_to_cpu(header->return_code);
232 230
@@ -256,7 +254,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
256 if (ret) 254 if (ret)
257 goto out_locality; 255 goto out_locality;
258 256
259 ret = tpm_try_transmit(chip, space, buf, bufsiz, flags); 257 ret = tpm_try_transmit(chip, buf, bufsiz, flags);
260 258
261 /* This may fail but do not override ret. */ 259 /* This may fail but do not override ret. */
262 tpm_go_idle(chip, flags); 260 tpm_go_idle(chip, flags);
@@ -302,7 +300,6 @@ out_locality:
302/** 300/**
303 * tpm_transmit_cmd - send a tpm command to the device 301 * tpm_transmit_cmd - send a tpm command to the device
304 * @chip: a TPM chip to use 302 * @chip: a TPM chip to use
305 * @space: a TPM space
306 * @buf: a TPM command buffer 303 * @buf: a TPM command buffer
307 * @min_rsp_body_length: minimum expected length of response body 304 * @min_rsp_body_length: minimum expected length of response body
308 * @flags: TPM transmit flags 305 * @flags: TPM transmit flags
@@ -313,15 +310,15 @@ out_locality:
313 * * -errno - A system error 310 * * -errno - A system error
314 * * TPM_RC - A TPM error 311 * * TPM_RC - A TPM error
315 */ 312 */
316ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, 313ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
317 struct tpm_buf *buf, size_t min_rsp_body_length, 314 size_t min_rsp_body_length, unsigned int flags,
318 unsigned int flags, const char *desc) 315 const char *desc)
319{ 316{
320 const struct tpm_header *header = (struct tpm_header *)buf->data; 317 const struct tpm_header *header = (struct tpm_header *)buf->data;
321 int err; 318 int err;
322 ssize_t len; 319 ssize_t len;
323 320
324 len = tpm_transmit(chip, space, buf->data, PAGE_SIZE, flags); 321 len = tpm_transmit(chip, buf->data, PAGE_SIZE, flags);
325 if (len < 0) 322 if (len < 0)
326 return len; 323 return len;
327 324
@@ -470,7 +467,7 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
470 goto out; 467 goto out;
471 468
472 memcpy(buf.data, cmd, buflen); 469 memcpy(buf.data, cmd, buflen);
473 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, 470 rc = tpm_transmit_cmd(chip, &buf, 0, 0,
474 "attempting to a send a command"); 471 "attempting to a send a command");
475 tpm_buf_destroy(&buf); 472 tpm_buf_destroy(&buf);
476out: 473out:
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index 928d4e839bb7..03e704f99ed6 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -52,9 +52,8 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
52 52
53 tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay)); 53 tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay));
54 54
55 rc = tpm_transmit_cmd(chip, NULL, &tpm_buf, 55 rc = tpm_transmit_cmd(chip, &tpm_buf, READ_PUBEK_RESULT_MIN_BODY_SIZE,
56 READ_PUBEK_RESULT_MIN_BODY_SIZE, 0, 56 0, "attempting to read the PUBEK");
57 "attempting to read the PUBEK");
58 if (rc) { 57 if (rc) {
59 tpm_buf_destroy(&tpm_buf); 58 tpm_buf_destroy(&tpm_buf);
60 return 0; 59 return 0;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index e84333259e28..644f1a5c4fdd 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -498,11 +498,11 @@ enum tpm_transmit_flags {
498 TPM_TRANSMIT_NESTED = BIT(1), 498 TPM_TRANSMIT_NESTED = BIT(1),
499}; 499};
500 500
501ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, 501ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
502 u8 *buf, size_t bufsiz, unsigned int flags); 502 unsigned int flags);
503ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, 503ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
504 struct tpm_buf *buf, size_t min_rsp_body_length, 504 size_t min_rsp_body_length, unsigned int flags,
505 unsigned int flags, const char *desc); 505 const char *desc);
506int tpm_get_timeouts(struct tpm_chip *); 506int tpm_get_timeouts(struct tpm_chip *);
507int tpm_auto_startup(struct tpm_chip *chip); 507int tpm_auto_startup(struct tpm_chip *chip);
508 508
diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c
index 10a0b7683b4b..5b5f8bcc6210 100644
--- a/drivers/char/tpm/tpm1-cmd.c
+++ b/drivers/char/tpm/tpm1-cmd.c
@@ -334,8 +334,7 @@ static int tpm1_startup(struct tpm_chip *chip)
334 334
335 tpm_buf_append_u16(&buf, TPM_ST_CLEAR); 335 tpm_buf_append_u16(&buf, TPM_ST_CLEAR);
336 336
337 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, 337 rc = tpm_transmit_cmd(chip, &buf, 0, 0, "attempting to start the TPM");
338 "attempting to start the TPM");
339 tpm_buf_destroy(&buf); 338 tpm_buf_destroy(&buf);
340 return rc; 339 return rc;
341} 340}
@@ -459,7 +458,7 @@ int tpm1_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash,
459 tpm_buf_append_u32(&buf, pcr_idx); 458 tpm_buf_append_u32(&buf, pcr_idx);
460 tpm_buf_append(&buf, hash, TPM_DIGEST_SIZE); 459 tpm_buf_append(&buf, hash, TPM_DIGEST_SIZE);
461 460
462 rc = tpm_transmit_cmd(chip, NULL, &buf, TPM_DIGEST_SIZE, 0, log_msg); 461 rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE, 0, log_msg);
463 tpm_buf_destroy(&buf); 462 tpm_buf_destroy(&buf);
464 return rc; 463 return rc;
465} 464}
@@ -489,7 +488,7 @@ ssize_t tpm1_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
489 tpm_buf_append_u32(&buf, 4); 488 tpm_buf_append_u32(&buf, 4);
490 tpm_buf_append_u32(&buf, subcap_id); 489 tpm_buf_append_u32(&buf, subcap_id);
491 } 490 }
492 rc = tpm_transmit_cmd(chip, NULL, &buf, min_cap_length, 0, desc); 491 rc = tpm_transmit_cmd(chip, &buf, min_cap_length, 0, desc);
493 if (!rc) 492 if (!rc)
494 *cap = *(cap_t *)&buf.data[TPM_HEADER_SIZE + 4]; 493 *cap = *(cap_t *)&buf.data[TPM_HEADER_SIZE + 4];
495 tpm_buf_destroy(&buf); 494 tpm_buf_destroy(&buf);
@@ -530,8 +529,7 @@ int tpm1_get_random(struct tpm_chip *chip, u8 *dest, size_t max)
530 do { 529 do {
531 tpm_buf_append_u32(&buf, num_bytes); 530 tpm_buf_append_u32(&buf, num_bytes);
532 531
533 rc = tpm_transmit_cmd(chip, NULL, &buf, 532 rc = tpm_transmit_cmd(chip, &buf, sizeof(out->rng_data_len), 0,
534 sizeof(out->rng_data_len), 0,
535 "attempting get random"); 533 "attempting get random");
536 if (rc) 534 if (rc)
537 goto out; 535 goto out;
@@ -576,7 +574,7 @@ int tpm1_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf)
576 574
577 tpm_buf_append_u32(&buf, pcr_idx); 575 tpm_buf_append_u32(&buf, pcr_idx);
578 576
579 rc = tpm_transmit_cmd(chip, NULL, &buf, TPM_DIGEST_SIZE, 0, 577 rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE, 0,
580 "attempting to read a pcr value"); 578 "attempting to read a pcr value");
581 if (rc) 579 if (rc)
582 goto out; 580 goto out;
@@ -610,7 +608,7 @@ static int tpm1_continue_selftest(struct tpm_chip *chip)
610 if (rc) 608 if (rc)
611 return rc; 609 return rc;
612 610
613 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, "continue selftest"); 611 rc = tpm_transmit_cmd(chip, &buf, 0, 0, "continue selftest");
614 tpm_buf_destroy(&buf); 612 tpm_buf_destroy(&buf);
615 return rc; 613 return rc;
616} 614}
@@ -736,7 +734,7 @@ int tpm1_pm_suspend(struct tpm_chip *chip, u32 tpm_suspend_pcr)
736 return rc; 734 return rc;
737 /* now do the actual savestate */ 735 /* now do the actual savestate */
738 for (try = 0; try < TPM_RETRY; try++) { 736 for (try = 0; try < TPM_RETRY; try++) {
739 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, NULL); 737 rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
740 /* 738 /*
741 * If the TPM indicates that it is too busy to respond to 739 * If the TPM indicates that it is too busy to respond to
742 * this command then retry before giving up. It can take 740 * this command then retry before giving up. It can take
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index ab03f8600f89..f2b0e5c52a57 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -197,7 +197,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf)
197 tpm_buf_append(&buf, (const unsigned char *)pcr_select, 197 tpm_buf_append(&buf, (const unsigned char *)pcr_select,
198 sizeof(pcr_select)); 198 sizeof(pcr_select));
199 199
200 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, res_buf ? 200 rc = tpm_transmit_cmd(chip, &buf, 0, 0, res_buf ?
201 "attempting to read a pcr value" : NULL); 201 "attempting to read a pcr value" : NULL);
202 if (rc == 0 && res_buf) { 202 if (rc == 0 && res_buf) {
203 out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE]; 203 out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
@@ -264,7 +264,7 @@ int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, u32 count,
264 } 264 }
265 } 265 }
266 266
267 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, 267 rc = tpm_transmit_cmd(chip, &buf, 0, 0,
268 "attempting extend a PCR value"); 268 "attempting extend a PCR value");
269 269
270 tpm_buf_destroy(&buf); 270 tpm_buf_destroy(&buf);
@@ -309,7 +309,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max)
309 do { 309 do {
310 tpm_buf_reset(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_RANDOM); 310 tpm_buf_reset(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_RANDOM);
311 tpm_buf_append_u16(&buf, num_bytes); 311 tpm_buf_append_u16(&buf, num_bytes);
312 err = tpm_transmit_cmd(chip, NULL, &buf, 312 err = tpm_transmit_cmd(chip, &buf,
313 offsetof(struct tpm2_get_random_out, 313 offsetof(struct tpm2_get_random_out,
314 buffer), 314 buffer),
315 0, "attempting get random"); 315 0, "attempting get random");
@@ -362,7 +362,7 @@ void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
362 362
363 tpm_buf_append_u32(&buf, handle); 363 tpm_buf_append_u32(&buf, handle);
364 364
365 tpm_transmit_cmd(chip, NULL, &buf, 0, flags, "flushing context"); 365 tpm_transmit_cmd(chip, &buf, 0, flags, "flushing context");
366 tpm_buf_destroy(&buf); 366 tpm_buf_destroy(&buf);
367} 367}
368 368
@@ -476,7 +476,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
476 goto out; 476 goto out;
477 } 477 }
478 478
479 rc = tpm_transmit_cmd(chip, NULL, &buf, 4, 0, "sealing data"); 479 rc = tpm_transmit_cmd(chip, &buf, 4, 0, "sealing data");
480 if (rc) 480 if (rc)
481 goto out; 481 goto out;
482 482
@@ -558,7 +558,7 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
558 goto out; 558 goto out;
559 } 559 }
560 560
561 rc = tpm_transmit_cmd(chip, NULL, &buf, 4, flags, "loading blob"); 561 rc = tpm_transmit_cmd(chip, &buf, 4, flags, "loading blob");
562 if (!rc) 562 if (!rc)
563 *blob_handle = be32_to_cpup( 563 *blob_handle = be32_to_cpup(
564 (__be32 *) &buf.data[TPM_HEADER_SIZE]); 564 (__be32 *) &buf.data[TPM_HEADER_SIZE]);
@@ -608,7 +608,7 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip,
608 options->blobauth /* hmac */, 608 options->blobauth /* hmac */,
609 TPM_DIGEST_SIZE); 609 TPM_DIGEST_SIZE);
610 610
611 rc = tpm_transmit_cmd(chip, NULL, &buf, 6, flags, "unsealing"); 611 rc = tpm_transmit_cmd(chip, &buf, 6, flags, "unsealing");
612 if (rc > 0) 612 if (rc > 0)
613 rc = -EPERM; 613 rc = -EPERM;
614 614
@@ -698,7 +698,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
698 tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES); 698 tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
699 tpm_buf_append_u32(&buf, property_id); 699 tpm_buf_append_u32(&buf, property_id);
700 tpm_buf_append_u32(&buf, 1); 700 tpm_buf_append_u32(&buf, 1);
701 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, NULL); 701 rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
702 if (!rc) { 702 if (!rc) {
703 out = (struct tpm2_get_cap_out *) 703 out = (struct tpm2_get_cap_out *)
704 &buf.data[TPM_HEADER_SIZE]; 704 &buf.data[TPM_HEADER_SIZE];
@@ -728,7 +728,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type)
728 if (rc) 728 if (rc)
729 return; 729 return;
730 tpm_buf_append_u16(&buf, shutdown_type); 730 tpm_buf_append_u16(&buf, shutdown_type);
731 tpm_transmit_cmd(chip, NULL, &buf, 0, 0, "stopping the TPM"); 731 tpm_transmit_cmd(chip, &buf, 0, 0, "stopping the TPM");
732 tpm_buf_destroy(&buf); 732 tpm_buf_destroy(&buf);
733} 733}
734 734
@@ -757,7 +757,7 @@ static int tpm2_do_selftest(struct tpm_chip *chip)
757 return rc; 757 return rc;
758 758
759 tpm_buf_append_u8(&buf, full); 759 tpm_buf_append_u8(&buf, full);
760 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, 760 rc = tpm_transmit_cmd(chip, &buf, 0, 0,
761 "attempting the self test"); 761 "attempting the self test");
762 tpm_buf_destroy(&buf); 762 tpm_buf_destroy(&buf);
763 763
@@ -794,7 +794,7 @@ int tpm2_probe(struct tpm_chip *chip)
794 tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES); 794 tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
795 tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS); 795 tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS);
796 tpm_buf_append_u32(&buf, 1); 796 tpm_buf_append_u32(&buf, 1);
797 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, NULL); 797 rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
798 /* We ignore TPM return codes on purpose. */ 798 /* We ignore TPM return codes on purpose. */
799 if (rc >= 0) { 799 if (rc >= 0) {
800 out = (struct tpm_header *)buf.data; 800 out = (struct tpm_header *)buf.data;
@@ -833,8 +833,7 @@ static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
833 tpm_buf_append_u32(&buf, 0); 833 tpm_buf_append_u32(&buf, 0);
834 tpm_buf_append_u32(&buf, 1); 834 tpm_buf_append_u32(&buf, 1);
835 835
836 rc = tpm_transmit_cmd(chip, NULL, &buf, 9, 0, 836 rc = tpm_transmit_cmd(chip, &buf, 9, 0, "get tpm pcr allocation");
837 "get tpm pcr allocation");
838 if (rc) 837 if (rc)
839 goto out; 838 goto out;
840 839
@@ -905,7 +904,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
905 tpm_buf_append_u32(&buf, TPM2_CC_FIRST); 904 tpm_buf_append_u32(&buf, TPM2_CC_FIRST);
906 tpm_buf_append_u32(&buf, nr_commands); 905 tpm_buf_append_u32(&buf, nr_commands);
907 906
908 rc = tpm_transmit_cmd(chip, NULL, &buf, 9 + 4 * nr_commands, 0, NULL); 907 rc = tpm_transmit_cmd(chip, &buf, 9 + 4 * nr_commands, 0, NULL);
909 if (rc) { 908 if (rc) {
910 tpm_buf_destroy(&buf); 909 tpm_buf_destroy(&buf);
911 goto out; 910 goto out;
@@ -962,8 +961,7 @@ static int tpm2_startup(struct tpm_chip *chip)
962 return rc; 961 return rc;
963 962
964 tpm_buf_append_u16(&buf, TPM2_SU_CLEAR); 963 tpm_buf_append_u16(&buf, TPM2_SU_CLEAR);
965 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, 0, 964 rc = tpm_transmit_cmd(chip, &buf, 0, 0, "attempting to start the TPM");
966 "attempting to start the TPM");
967 tpm_buf_destroy(&buf); 965 tpm_buf_destroy(&buf);
968 966
969 return rc; 967 return rc;
diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
index b9ada4abbcad..08bbd558dbc1 100644
--- a/drivers/char/tpm/tpm2-space.c
+++ b/drivers/char/tpm/tpm2-space.c
@@ -83,8 +83,7 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
83 body_size = sizeof(*ctx) + be16_to_cpu(ctx->blob_size); 83 body_size = sizeof(*ctx) + be16_to_cpu(ctx->blob_size);
84 tpm_buf_append(&tbuf, &buf[*offset], body_size); 84 tpm_buf_append(&tbuf, &buf[*offset], body_size);
85 85
86 rc = tpm_transmit_cmd(chip, NULL, &tbuf, 4, 86 rc = tpm_transmit_cmd(chip, &tbuf, 4, TPM_TRANSMIT_UNLOCKED, NULL);
87 TPM_TRANSMIT_UNLOCKED, NULL);
88 if (rc < 0) { 87 if (rc < 0) {
89 dev_warn(&chip->dev, "%s: failed with a system error %d\n", 88 dev_warn(&chip->dev, "%s: failed with a system error %d\n",
90 __func__, rc); 89 __func__, rc);
@@ -132,8 +131,7 @@ static int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf,
132 131
133 tpm_buf_append_u32(&tbuf, handle); 132 tpm_buf_append_u32(&tbuf, handle);
134 133
135 rc = tpm_transmit_cmd(chip, NULL, &tbuf, 0, 134 rc = tpm_transmit_cmd(chip, &tbuf, 0, TPM_TRANSMIT_UNLOCKED, NULL);
136 TPM_TRANSMIT_UNLOCKED, NULL);
137 if (rc < 0) { 135 if (rc < 0) {
138 dev_warn(&chip->dev, "%s: failed with a system error %d\n", 136 dev_warn(&chip->dev, "%s: failed with a system error %d\n",
139 __func__, rc); 137 __func__, rc);
diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
index 986d7e8147b8..8678c4bba38a 100644
--- a/drivers/char/tpm/tpm_vtpm_proxy.c
+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
@@ -416,7 +416,7 @@ static int vtpm_proxy_request_locality(struct tpm_chip *chip, int locality)
416 416
417 proxy_dev->state |= STATE_DRIVER_COMMAND; 417 proxy_dev->state |= STATE_DRIVER_COMMAND;
418 418
419 rc = tpm_transmit_cmd(chip, NULL, &buf, 0, TPM_TRANSMIT_NESTED, 419 rc = tpm_transmit_cmd(chip, &buf, 0, TPM_TRANSMIT_NESTED,
420 "attempting to set locality"); 420 "attempting to set locality");
421 421
422 proxy_dev->state &= ~STATE_DRIVER_COMMAND; 422 proxy_dev->state &= ~STATE_DRIVER_COMMAND;