Skip to content

Commit

Permalink
uffd: Resource leak (RESOURCE_LEAK)
Browse files Browse the repository at this point in the history
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

Signed-off-by: Adrian Reber <[email protected]>
  • Loading branch information
adrianreber committed Sep 28, 2020
1 parent 84485c3 commit 3a21ac3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions criu/uffd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ static int prepare_uffds(int listen, int epollfd)

int cr_lazy_pages(bool daemon)
{
struct epoll_event *events;
struct epoll_event *events = NULL;
int nr_fds;
int lazy_sk;
int ret;
Expand Down Expand Up @@ -1466,20 +1466,28 @@ int cr_lazy_pages(bool daemon)
*/
nr_fds = task_entries->nr_tasks + (opts.use_page_server ? 2 : 1);
epollfd = epoll_prepare(nr_fds, &events);
if (epollfd < 0)
if (epollfd < 0) {
if (events)
xfree(events);
return -1;
}

if (prepare_uffds(lazy_sk, epollfd))
if (prepare_uffds(lazy_sk, epollfd)) {
xfree(events);
return -1;
}

if (opts.use_page_server) {
if (connect_to_page_server_to_recv(epollfd))
if (connect_to_page_server_to_recv(epollfd)) {
xfree(events);
return -1;
}
}

ret = handle_requests(epollfd, events, nr_fds);

tls_terminate_session();

xfree(events);
return ret;
}

0 comments on commit 3a21ac3

Please sign in to comment.