git: b3564c233749 - main - bhyve: use assert for missing TPM version
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Jun 2023 06:23:01 UTC
The branch main has been updated by corvink:
URL: https://cgit.FreeBSD.org/src/commit/?id=b3564c2337490f40747198dae3206459fa186ac1
commit b3564c2337490f40747198dae3206459fa186ac1
Author: Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-06-15 08:36:37 +0000
Commit: Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-06-16 06:18:08 +0000
bhyve: use assert for missing TPM version
The TPM version config node should always be set. If it's not set,
there's a bug in our code. An assertion is the correct way to check for
this.
Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40558
---
usr.sbin/bhyve/tpm_device.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/usr.sbin/bhyve/tpm_device.c b/usr.sbin/bhyve/tpm_device.c
index 56df6ab0e30c..e48f9df14701 100644
--- a/usr.sbin/bhyve/tpm_device.c
+++ b/usr.sbin/bhyve/tpm_device.c
@@ -7,6 +7,7 @@
#include <sys/types.h>
+#include <assert.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
@@ -54,7 +55,8 @@ tpm_device_create(struct tpm_device **const new_dev, struct vmctx *const vm_ctx,
}
value = get_config_value_node(nvl, "version");
- if (value == NULL || strcmp(value, "2.0")) {
+ assert(value != NULL);
+ if (strcmp(value, "2.0")) {
warnx("%s: unsupported tpm version %s", __func__, value);
error = EINVAL;
goto err_out;