qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@gmail.com
Subject: Re: [Qemu-devel] [PATCH v5.2 for 2.13 1/4] tpm: extend TPM emulator with state migration support
Date: Wed, 21 Mar 2018 17:57:48 -0400	[thread overview]
Message-ID: <ec539c1c-37bb-afaf-9a8b-99e6c4f44f4f@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180321171402.GF3465@work-vm>

On 03/21/2018 01:14 PM, Dr. David Alan Gilbert wrote:
> * Stefan Berger (stefanb@linux.vnet.ibm.com) wrote:
>> +
>> +    if (totlength > 0) {
>> +        tsb->buffer = g_try_malloc(totlength);
>> +        if (!tsb->buffer) {
>> +            error_report("tpm-emulator: Out of memory allocating %u bytes",
>> +                         totlength);
>> +            return -1;
>> +        }
>> +
>> +        n = qemu_chr_fe_read_all(&tpm_emu->ctrl_chr, tsb->buffer, totlength);
>> +        if (n != totlength) {
>> +            error_report("tpm-emulator: Could not read stateblob (type %d); "
>> +                         "expected %u bytes, got %zd",
>> +                         type, totlength, n);
> I think you need to free tsb->buffer here.

tpm_emulator_get_state_blobs() below clears all 3 buffers in case one 
error is encountered.

>
> Other than that, I think:
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
>
>> +            return -1;
>> +        }
>> +    }
>> +    tsb->size = totlength;
>> +
>> +    trace_tpm_emulator_get_state_blob(type, tsb->size, *flags);
>> +
>> +    return 0;
>> +}
>> +
>> +static int tpm_emulator_get_state_blobs(TPMEmulator *tpm_emu)
>> +{
>> +    TPMBlobBuffers *state_blobs = &tpm_emu->state_blobs;
>> +
>> +    if (tpm_emulator_get_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT,
>> +                                    &state_blobs->permanent,
>> +                                    &state_blobs->permanent_flags) < 0 ||
>> +        tpm_emulator_get_state_blob(tpm_emu, PTM_BLOB_TYPE_VOLATILE,
>> +                                    &state_blobs->volatil,
>> +                                    &state_blobs->volatil_flags) < 0 ||
>> +        tpm_emulator_get_state_blob(tpm_emu, PTM_BLOB_TYPE_SAVESTATE,
>> +                                    &state_blobs->savestate,
>> +                                    &state_blobs->savestate_flags) < 0) {
>> +        goto err_exit;
>> +    }
>> +
>> +    return 0;
>> +
>> + err_exit:
>> +    tpm_sized_buffer_reset(&state_blobs->volatil);
>> +    tpm_sized_buffer_reset(&state_blobs->permanent);
>> +    tpm_sized_buffer_reset(&state_blobs->savestate);

^^^ here

>> +
>> +    return -1;
>> +}

  reply	other threads:[~2018-03-21 21:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-17  2:24 [Qemu-devel] [PATCH v5.2 for 2.13 0/4] tpm: Extend TPM with state migration support Stefan Berger
2018-03-17  2:24 ` [Qemu-devel] [PATCH v5.2 for 2.13 1/4] tpm: extend TPM emulator " Stefan Berger
2018-03-21 17:14   ` Dr. David Alan Gilbert
2018-03-21 21:57     ` Stefan Berger [this message]
2018-03-22  9:07       ` Dr. David Alan Gilbert
2018-03-17  2:24 ` [Qemu-devel] [PATCH v5.2 for 2.13 2/4] tpm: extend TPM TIS " Stefan Berger
2018-03-21 18:21   ` Dr. David Alan Gilbert
2018-03-17  2:24 ` [Qemu-devel] [PATCH v5.2 for 2.13 3/4] docs: tpm: add VM save/restore example and troubleshooting guide Stefan Berger
2018-03-21 18:42   ` Dr. David Alan Gilbert
2018-03-21 22:19     ` Stefan Berger
2018-03-23 20:13       ` Dr. David Alan Gilbert
2018-03-17  2:24 ` [Qemu-devel] [PATCH v5.2 for 2.13 4/4] tpm: Add test cases that uses the external swtpm with CRB interface Stefan Berger
2018-03-21 19:51   ` Dr. David Alan Gilbert
2018-03-28 15:56   ` Marc-André Lureau
2018-03-21 20:04 ` [Qemu-devel] [PATCH v5.2 for 2.13 0/4] tpm: Extend TPM with state migration support Dr. David Alan Gilbert
2018-03-21 21:48   ` Stefan Berger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec539c1c-37bb-afaf-9a8b-99e6c4f44f4f@linux.vnet.ibm.com \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=dgilbert@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).