mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-03 18:46:33 +00:00
refine 'assert' usage in vmmapi.c and main.c
cleanup 'assert' to avoid possible software vulnerabilities Tracked-On: #3252 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
parent
dedf9befa6
commit
65d7d83b1c
@ -33,7 +33,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -654,10 +653,15 @@ vm_loop(struct vmctx *ctx)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
ctx->ioreq_client = vm_create_ioreq_client(ctx);
|
ctx->ioreq_client = vm_create_ioreq_client(ctx);
|
||||||
assert(ctx->ioreq_client > 0);
|
if (ctx->ioreq_client <= 0) {
|
||||||
|
pr_err("%s, failed to create IOREQ.\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
error = vm_run(ctx);
|
if (vm_run(ctx) != 0) {
|
||||||
assert(error == 0);
|
pr_err("%s, failed to run VM.\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int vcpu_id;
|
int vcpu_id;
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -98,8 +97,8 @@ vm_create(const char *name, uint64_t req_buf)
|
|||||||
|
|
||||||
memset(&create_vm, 0, sizeof(struct acrn_create_vm));
|
memset(&create_vm, 0, sizeof(struct acrn_create_vm));
|
||||||
ctx = calloc(1, sizeof(struct vmctx) + strnlen(name, PATH_MAX) + 1);
|
ctx = calloc(1, sizeof(struct vmctx) + strnlen(name, PATH_MAX) + 1);
|
||||||
assert(ctx != NULL);
|
if ((ctx == NULL) || (devfd != -1))
|
||||||
assert(devfd == -1);
|
goto err;
|
||||||
|
|
||||||
if (stat("/dev/acrn_vhm", &tmp_st) == 0) {
|
if (stat("/dev/acrn_vhm", &tmp_st) == 0) {
|
||||||
devfd = open("/dev/acrn_vhm", O_RDWR|O_CLOEXEC);
|
devfd = open("/dev/acrn_vhm", O_RDWR|O_CLOEXEC);
|
||||||
@ -174,7 +173,9 @@ vm_create(const char *name, uint64_t req_buf)
|
|||||||
return ctx;
|
return ctx;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free(ctx);
|
if (ctx != NULL)
|
||||||
|
free(ctx);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user