mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
fix many unclosed file opened by open_image_ro
Many image files opened by open_image_ro weren't closed before return, fix them all in this patch. Signed-off-by: Huang Qiang <h.huangqiang@huawei.com> Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
cf698a9a48
commit
223dce83c2
20
files.c
20
files.c
@@ -576,20 +576,21 @@ int prepare_fs(int pid)
|
||||
if (ifd < 0)
|
||||
return -1;
|
||||
|
||||
if (pb_read_one(ifd, &fe, PB_FS) < 0)
|
||||
if (pb_read_one(ifd, &fe, PB_FS) < 0) {
|
||||
close_safe(&ifd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cwd = open_reg_by_id(fe->cwd_id);
|
||||
if (cwd < 0)
|
||||
goto err;
|
||||
|
||||
if (fchdir(cwd) < 0) {
|
||||
pr_perror("Can't change root");
|
||||
if (cwd < 0) {
|
||||
close_safe(&ifd);
|
||||
goto err;
|
||||
}
|
||||
|
||||
close(cwd);
|
||||
close(ifd);
|
||||
if (fchdir(cwd) < 0) {
|
||||
pr_perror("Can't change root");
|
||||
goto close;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: restore task's root. Don't want to do it now, since
|
||||
@@ -601,6 +602,9 @@ int prepare_fs(int pid)
|
||||
*/
|
||||
|
||||
ret = 0;
|
||||
close:
|
||||
close_safe(&cwd);
|
||||
close_safe(&ifd);
|
||||
err:
|
||||
fs_entry__free_unpacked(fe, NULL);
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user