static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id) { Object *obj = object_new(TYPE_TPM_PASSTHROUGH); TPMBackend *tb = TPM_BACKEND(obj); TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); tb->id = g_strdup(id); /* let frontend set the fe_model to proper value */ tb->fe_model = -1; tb->ops = &tpm_passthrough_driver; if (tpm_passthrough_handle_device_opts(opts, tb)) { goto err_exit; } tpm_pt->cancel_fd = tpm_passthrough_open_sysfs_cancel(tb); if (tpm_pt->cancel_fd < 0) { goto err_exit; } return tb; err_exit: g_free(tb->id); return NULL; }
static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id) { TPMBackend *tb; tb = g_new0(TPMBackend, 1); tb->s.tpm_pt = g_new0(TPMPassthruState, 1); tb->id = g_strdup(id); /* let frontend set the fe_model to proper value */ tb->fe_model = -1; tb->ops = &tpm_passthrough_driver; if (tpm_passthrough_handle_device_opts(opts, tb)) { goto err_exit; } tb->s.tpm_pt->cancel_fd = tpm_passthrough_open_sysfs_cancel(tb); if (tb->s.tpm_pt->cancel_fd < 0) { goto err_exit; } return tb; err_exit: g_free(tb->id); g_free(tb->s.tpm_pt); g_free(tb); return NULL; }