Commit 8df4d848 authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Stefan Berger
Browse files

tpm-passthrough: make it safer to destroy after creation



Check fds values before closing, to avoid close(-1).

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
parent 9f7c0ef2
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -347,8 +347,12 @@ static void tpm_passthrough_inst_finalize(Object *obj)

    tpm_passthrough_cancel_cmd(TPM_BACKEND(obj));

    if (tpm_pt->tpm_fd >= 0) {
        qemu_close(tpm_pt->tpm_fd);
    }
    if (tpm_pt->cancel_fd >= 0) {
        qemu_close(tpm_pt->cancel_fd);
    }
    qapi_free_TPMPassthroughOptions(tpm_pt->options);
}