[CRIU] [PATCH] criu: don't leak a service fd

Andrei Vagin avagin at gmail.com
Tue Nov 27 21:06:02 MSK 2018


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 <avagin at gmail.com>
---
 criu/util.c | 2 ++
 1 file changed, 2 insertions(+)

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)
 		sfds_protection_bug(type);
 
 	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;
-- 
2.14.4



More information about the CRIU mailing list