File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 33
33
#include <errno.h>
34
34
#include <libgen.h>
35
35
#include <unistd.h>
36
- #include <assert.h>
37
36
#include <pthread.h>
38
37
#include <sysexits.h>
39
38
#include <stdbool.h>
@@ -654,10 +653,15 @@ vm_loop(struct vmctx *ctx)
654
653
int error ;
655
654
656
655
ctx -> ioreq_client = vm_create_ioreq_client (ctx );
657
- assert (ctx -> ioreq_client > 0 );
656
+ if (ctx -> ioreq_client <= 0 ) {
657
+ pr_err ("%s, failed to create IOREQ.\n" , __func__ );
658
+ return ;
659
+ }
658
660
659
- error = vm_run (ctx );
660
- assert (error == 0 );
661
+ if (vm_run (ctx ) != 0 ) {
662
+ pr_err ("%s, failed to run VM.\n" , __func__ );
663
+ return ;
664
+ }
661
665
662
666
while (1 ) {
663
667
int vcpu_id ;
Original file line number Diff line number Diff line change 32
32
#include <stdio.h>
33
33
#include <stdlib.h>
34
34
#include <stdbool.h>
35
- #include <assert.h>
36
35
#include <string.h>
37
36
#include <ctype.h>
38
37
#include <fcntl.h>
@@ -98,8 +97,8 @@ vm_create(const char *name, uint64_t req_buf)
98
97
99
98
memset (& create_vm , 0 , sizeof (struct acrn_create_vm ));
100
99
ctx = calloc (1 , sizeof (struct vmctx ) + strnlen (name , PATH_MAX ) + 1 );
101
- assert ( ctx != NULL );
102
- assert ( devfd == -1 ) ;
100
+ if (( ctx == NULL ) || ( devfd != -1 ))
101
+ goto err ;
103
102
104
103
if (stat ("/dev/acrn_vhm" , & tmp_st ) == 0 ) {
105
104
devfd = open ("/dev/acrn_vhm" , O_RDWR |O_CLOEXEC );
@@ -174,7 +173,9 @@ vm_create(const char *name, uint64_t req_buf)
174
173
return ctx ;
175
174
176
175
err :
177
- free (ctx );
176
+ if (ctx != NULL )
177
+ free (ctx );
178
+
178
179
return NULL ;
179
180
}
180
181
You can’t perform that action at this time.
0 commit comments