mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
mount: fix cwd_fd leak on clone error
We should close cwd_fd on error paths, found by Coverity Scan:
*** CID 187162: Resource leaks (RESOURCE_LEAK)
/criu/mount.c: 1370 in open_mountpoint()
1364 */
1365 pid = clone_noasan(ns_open_mountpoint, CLONE_VFORK | CLONE_VM
1366 | CLONE_FILES | CLONE_IO | CLONE_SIGHAND
1367 | CLONE_SYSVSEM, &ca);
1368 if (pid == -1) {
1369 pr_perror("Can't clone helper process");
>>> CID 187162: Resource leaks (RESOURCE_LEAK)
>>> Handle variable "cwd_fd" going out of scope leaks the handle.
1370 return -1;
1371 }
1372
1373 errno = 0;
1374 if (waitpid(pid, &status, __WALL) != pid || !WIFEXITED(status)
1375 || WEXITSTATUS(status)) {
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
455b96c078
commit
f48bf9825f
1 changed files with 2 additions and 2 deletions
|
|
@ -1367,7 +1367,7 @@ int open_mountpoint(struct mount_info *pm)
|
|||
| CLONE_SYSVSEM, &ca);
|
||||
if (pid == -1) {
|
||||
pr_perror("Can't clone helper process");
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
|
|
@ -1375,7 +1375,7 @@ int open_mountpoint(struct mount_info *pm)
|
|||
|| WEXITSTATUS(status)) {
|
||||
pr_err("Can't wait or bad status: errno=%d, status=%d\n",
|
||||
errno, status);
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue