criu: don't leak a service fd

Submitted by Andrei Vagin on Nov. 27, 2018, 6:06 p.m.


Message ID
State Accepted
Series "criu: don't leak a service fd"
Headers show

Commit Message

Andrei Vagin Nov. 27, 2018, 6:06 p.m.
Recently, I introduced a new mode when a service fd are not dupped into
a fixed file descriptor number. A side effect of this is that we need to
close the old descritpor if it was installed.

Fixes: d3499999676d ("criu: remove all magic of service-fd when it isn't required")
Signed-off-by: Andrei Vagin <>
 criu/util.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index a2be58ab0..87c544dfe 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -495,6 +495,8 @@  int install_service_fd(enum sfd_type type, int fd)
 	if (service_fd_base == 0) {
+		if (test_bit(type, sfd_map))
+			close(sfd_arr[type]);
 		sfd_arr[type] = fd;
 		set_bit(type, sfd_map);
 		return fd;