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

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]>
  • Loading branch information
adrianreber authored and avagin committed Oct 1, 2020
1 parent 1886899 commit e0641d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 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 @@ -1469,17 +1469,22 @@ int cr_lazy_pages(bool daemon)
if (epollfd < 0)
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;
}
2 changes: 1 addition & 1 deletion criu/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ int epoll_prepare(int nr_fds, struct epoll_event **events)
return -1;

epollfd = epoll_create(nr_fds);
if (epollfd == -1) {
if (epollfd < 0) {
pr_perror("epoll_create failed");
goto free_events;
}
Expand Down

0 comments on commit e0641d2

Please sign in to comment.