[CRIU] [PATCH] unix: handle unlink failure correctly

Tycho Andersen tycho.andersen at canonical.com
Tue Jul 19 07:41:42 PDT 2016


Instead of returning, we should revert the cwd as in all the other error
paths.

*** CID 164720:  Resource leaks  (RESOURCE_LEAK)
/criu/sk-unix.c: 1030 in bind_unix_sk()
1024                                    goto done;
1025                            }
1026                    }
1027
1028                    if (ui->ue->deleted && unlink((char
*)ui->ue->name.data) < 0) {
1029                            pr_perror("failed to unlink %s\n",
ui->ue->name.data);
>>>     CID 164720:  Resource leaks  (RESOURCE_LEAK)
>>>     Handle variable "cwd_fd" going out of scope leaks the handle.
1030                            return -1;
1031                    }
1032            }
1033
1034            if (ui->ue->state != TCP_LISTEN)
1035                    futex_set_and_wake(&ui->prepared, 1);

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
CC: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/sk-unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 9021c9a..2bab17f 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1027,7 +1027,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui)
 
 		if (ui->ue->deleted && unlink((char *)ui->ue->name.data) < 0) {
 			pr_perror("failed to unlink %s\n", ui->ue->name.data);
-			return -1;
+			goto done;
 		}
 	}
 
-- 
2.7.4



More information about the CRIU mailing list