Commit 40a37ae7 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

unix: handle unlink failure correctly

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: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 69c69601
...@@ -1027,7 +1027,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui) ...@@ -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) { if (ui->ue->deleted && unlink((char *)ui->ue->name.data) < 0) {
pr_perror("failed to unlink %s\n", ui->ue->name.data); pr_perror("failed to unlink %s\n", ui->ue->name.data);
return -1; goto done;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment