Commit bcfff83
tpm: dynamically allocate the allocated_banks array
This patch renames active_banks (member of tpm_chip) to allocated_banks,
stores the number of allocated PCR banks in nr_allocated_banks (new member
of tpm_chip), and replaces the static array with a pointer to a dynamically
allocated array.
tpm2_get_pcr_allocation() determines if a PCR bank is allocated by checking
the mask in the TPML_PCR_SELECTION structure returned by the TPM for
TPM2_Get_Capability(). If a bank is not allocated, the TPM returns that
bank in TPML_PCR_SELECTION, with all bits in the mask set to zero. In this
case, the bank is not included in chip->allocated_banks, to avoid that TPM
driver users unnecessarily calculate a digest for that bank.
One PCR bank with algorithm set to SHA1 is always allocated for TPM 1.x.
As a consequence of the introduction of nr_allocated_banks,
tpm_pcr_extend() does not check anymore if the algorithm stored in tpm_chip
is equal to zero.
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>1 parent 47a6c28 commit bcfff83
File tree
5 files changed
+44
-19
lines changed- drivers/char/tpm
5 files changed
+44
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
322 | | - | |
| 321 | + | |
323 | 322 | | |
324 | 323 | | |
325 | 324 | | |
326 | 325 | | |
327 | 326 | | |
328 | 327 | | |
329 | 328 | | |
330 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
331 | 333 | | |
332 | | - | |
333 | | - | |
334 | | - | |
| 334 | + | |
| 335 | + | |
335 | 336 | | |
336 | | - | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
340 | 342 | | |
341 | 343 | | |
342 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
699 | 709 | | |
700 | 710 | | |
701 | 711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
811 | | - | |
812 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
| |||
826 | 828 | | |
827 | 829 | | |
828 | 830 | | |
829 | | - | |
| 831 | + | |
830 | 832 | | |
831 | 833 | | |
832 | | - | |
833 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
834 | 839 | | |
835 | 840 | | |
836 | 841 | | |
| |||
839 | 844 | | |
840 | 845 | | |
841 | 846 | | |
842 | | - | |
| 847 | + | |
843 | 848 | | |
844 | 849 | | |
845 | 850 | | |
| |||
848 | 853 | | |
849 | 854 | | |
850 | 855 | | |
851 | | - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
852 | 865 | | |
853 | 866 | | |
854 | 867 | | |
855 | 868 | | |
856 | 869 | | |
857 | 870 | | |
| 871 | + | |
858 | 872 | | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | 873 | | |
863 | 874 | | |
864 | 875 | | |
| |||
0 commit comments