[CRIU] [PATCH] tun: don't leak a file descriptor

Andrei Vagin avagin at virtuozzo.com
Wed May 16 01:58:15 MSK 2018


CID 84654 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/tun.c b/criu/tun.c
index dbc471158..8274ccb8d 100644
--- a/criu/tun.c
+++ b/criu/tun.c
@@ -371,7 +371,7 @@ static int tunfile_open(struct file_desc *d, int *new_fd)
 
 	ns_id = ti->tfe->has_ns_id ? ti->tfe->ns_id : top_net_ns->id;
 	if (set_netns(ns_id))
-		return -1;
+		goto err;
 
 	if (!ti->tfe->netdev)
 		/* just-opened tun file */
-- 
2.14.3



More information about the CRIU mailing list