lkml.org 
[lkml]   [2018]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 1/6] tpm: dynamically allocate active_banks array
From
Date
On Wed, 2018-11-07 at 11:44 +0530, Nayna Jain wrote:
> On 11/06/2018 08:31 PM, Roberto Sassu wrote:


> > @@ -878,11 +877,14 @@ static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
> > if (rc)
> > goto out;
> >
> > - count = be32_to_cpup(
> > + chip->nr_active_banks = be32_to_cpup(
> > (__be32 *)&buf.data[TPM_HEADER_SIZE + 5]);
>
>
> As per my understanding, the count in the TPML_PCR_SELECTION represent
> the number of possible banks and not the number of active banks.
> TCG Structures Spec for TPM 2.0 - Table 102 mentions this as explanation
> of #TPM_RC_SIZE.

Instead of storing the result in a local variable, the only change
here is saving the result in the chip info (nr_active_banks).
 Everything else remains the same.


> >
> > - if (count > ARRAY_SIZE(chip->active_banks)) {
> > - rc = -ENODEV;
> > + chip->active_banks = kmalloc_array(chip->nr_active_banks,
> > + sizeof(*chip->active_banks),
> > + GFP_KERNEL);

With this change, the exact number of banks can be allocated, as done
here.  Nice! 

Mimi

> > + if (!chip->active_banks) {
> > + rc = -ENOMEM;
> > goto out;
> > }
> >
>

\
 
 \ /
  Last update: 2018-11-07 13:08    [W:0.179 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site