Skip to content

Commit 33e2384

Browse files
adrianreberavagin
authored andcommitted
uffd: Resource leak (RESOURCE_LEAK)
CID 226485 (#1 of 3): Resource leak (RESOURCE_LEAK) Variable events going out of scope leaks the storage it points to CID 226485 (#2 of 3): Resource leak (RESOURCE_LEAK) Variable events going out of scope leaks the storage it points to CID 226485 (#3 of 3): Resource leak (RESOURCE_LEAK) Variable events going out of scope leaks the storage it points to Also changed epoll_prepare() to check return value of epoll_create() against '< 0' instead if '== -1' to make coverity happy. Signed-off-by: Adrian Reber <[email protected]>
1 parent dfa45b1 commit 33e2384

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

criu/uffd.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static int prepare_uffds(int listen, int epollfd)
14211421

14221422
int cr_lazy_pages(bool daemon)
14231423
{
1424-
struct epoll_event *events;
1424+
struct epoll_event *events = NULL;
14251425
int nr_fds;
14261426
int lazy_sk;
14271427
int ret;
@@ -1469,17 +1469,22 @@ int cr_lazy_pages(bool daemon)
14691469
if (epollfd < 0)
14701470
return -1;
14711471

1472-
if (prepare_uffds(lazy_sk, epollfd))
1472+
if (prepare_uffds(lazy_sk, epollfd)) {
1473+
xfree(events);
14731474
return -1;
1475+
}
14741476

14751477
if (opts.use_page_server) {
1476-
if (connect_to_page_server_to_recv(epollfd))
1478+
if (connect_to_page_server_to_recv(epollfd)) {
1479+
xfree(events);
14771480
return -1;
1481+
}
14781482
}
14791483

14801484
ret = handle_requests(epollfd, events, nr_fds);
14811485

14821486
tls_terminate_session();
14831487

1488+
xfree(events);
14841489
return ret;
14851490
}

criu/util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ int epoll_prepare(int nr_fds, struct epoll_event **events)
12891289
return -1;
12901290

12911291
epollfd = epoll_create(nr_fds);
1292-
if (epollfd == -1) {
1292+
if (epollfd < 0) {
12931293
pr_perror("epoll_create failed");
12941294
goto free_events;
12951295
}

0 commit comments

Comments
 (0)