git: 3256b7ca36e7 - main - bhyve: avoid an empty passthru config value
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Apr 2022 09:19:43 UTC
The branch main has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=3256b7ca36e739a08f141a7ee52b9db9d995db85
commit 3256b7ca36e739a08f141a7ee52b9db9d995db85
Author: Corvin Köhne <CorvinK@beckhoff.com>
AuthorDate: 2022-04-01 08:20:55 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-04-01 09:13:16 +0000
bhyve: avoid an empty passthru config value
pci_parse_legacy_config splits the options string by comma characters.
strchr returns a pointer to the first occurence of a character. In that
case, it's a comma. So, pci_parse_legacy_config will stop at the first
character and creates a new config node with a name of NULL.
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D34600
---
usr.sbin/bhyve/pci_passthru.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c
index 3cb0649f4741..153554f97e43 100644
--- a/usr.sbin/bhyve/pci_passthru.c
+++ b/usr.sbin/bhyve/pci_passthru.c
@@ -662,7 +662,12 @@ passthru_legacy_config(nvlist_t *nvl, const char *opts)
snprintf(value, sizeof(value), "%d", func);
set_config_value_node(nvl, "func", value);
- return (pci_parse_legacy_config(nvl, strchr(opts, ',')));
+ opts = strchr(opts, ',');
+ if (opts == NULL) {
+ return (0);
+ }
+
+ return pci_parse_legacy_config(nvl, opts + 1);
}
static int