Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163141759
D56346.id175244.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D56346.id175244.diff
View Options
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
+ * Copyright (c) 2026 Hans Rosenfeld
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -218,6 +219,9 @@
struct vcpu *vcpu;
vcpu = malloc(sizeof(*vcpu));
+ if (vcpu == NULL)
+ return (vcpu);
+
vcpu->ctx = ctx;
vcpu->vcpuid = vcpuid;
return (vcpu);
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
+ * Copyright (c) 2026 Hans Rosenfeld
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -917,6 +918,12 @@
}
bsp = vm_vcpu_open(ctx, BSP);
+ if (bsp == NULL) {
+ fprintf(stderr, "Unable to open boot VCPU: %s",
+ strerror(errno));
+ exit(BHYVE_EXIT_ERROR);
+ }
+
max_vcpus = num_vcpus_allowed(ctx, bsp);
if (guest_ncpus > max_vcpus) {
fprintf(stderr, "%d vCPUs requested but only %d available\n",
@@ -935,6 +942,12 @@
vcpu_info[vcpuid].vcpu = bsp;
else
vcpu_info[vcpuid].vcpu = vm_vcpu_open(ctx, vcpuid);
+
+ if (vcpu_info[vcpuid].vcpu == NULL) {
+ fprintf(stderr, "Unable to open VCPU %d: %s", vcpuid,
+ strerror(errno));
+ exit(BHYVE_EXIT_ERROR);
+ }
}
if (bhyve_init_platform(ctx, bsp) != 0)
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
+ * Copyright (c) 2026 Hans Rosenfeld
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -408,6 +409,12 @@
exit(1);
}
vcpu = vm_vcpu_open(ctx, vcpuid);
+ if (vcpu == NULL) {
+ fprintf(stderr,
+ "vm_vcpu_open: %s vcpu %d could not be opened: %s\n",
+ vmname, vcpuid, strerror(errno));
+ exit(1);
+ }
error = 0;
if (!error && memsize)
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -892,6 +892,8 @@
}
vcpu = vm_vcpu_open(ctx, BSP);
+ if (vcpu == NULL)
+ err(1, "vm_vcpu_open");
caph_cache_catpages();
if (caph_enter() < 0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 21, 11:38 AM (4 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35315079
Default Alt Text
D56346.id175244.diff (2 KB)
Attached To
Mode
D56346: libvmmapi: Check for allocation failure in vm_vcpu_open()
Attached
Detach File
Event Timeline
Log In to Comment