Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 59abb74

Browse files
authored
Merge pull request #342 from Weichen81/lkvm
Fix guest kernel crashed when hyperstart handle SETUPROUTE
2 parents 5b14ad0 + ad48a32 commit 59abb74

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static int hyper_setup_route(struct rtnl_handle *rth,
302302
char buf[1024];
303303
} req;
304304

305-
if (!rt->dst) {
305+
if (!rt || !rt->dst) {
306306
fprintf(stderr, "route dest is null\n");
307307
return -1;
308308
}

src/parse.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,12 @@ int hyper_parse_setup_routes(struct hyper_route **routes, uint32_t *r_num, char
10231023
jsmntok_t *toks = NULL;
10241024
int found = 0;
10251025

1026+
/*
1027+
* If we could not find routes from JSON, we have to set r_num to 0,
1028+
* this will avid returning a random number for r_num.
1029+
*/
1030+
*r_num = 0;
1031+
10261032
realloc:
10271033
toks = realloc(toks, toks_num * sizeof(jsmntok_t));
10281034
if (toks == NULL) {

0 commit comments

Comments
 (0)