mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-27 03:56:05 +00:00
filesystem: Double close (USE_AFTER_FREE)
CID 226484 (#1 of 1): Double close (USE_AFTER_FREE) Calling close(int) closes handle fd which has already been closed. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
parent
38246bf554
commit
2a4c4bf2fc
2 changed files with 7 additions and 2 deletions
|
|
@ -656,7 +656,6 @@ static int dump_empty_fs(struct mount_info *pm)
|
|||
return fd;
|
||||
|
||||
ret = is_empty_dir(fd);
|
||||
close(fd);
|
||||
if (ret < 0) {
|
||||
pr_err("%s isn't empty\n", pm->fstype->name);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -709,6 +709,10 @@ int is_root_user(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* is_empty_dir will always close the FD dirfd: either implicitly
|
||||
* via closedir or explicitly in case fdopendir had failed
|
||||
*/
|
||||
int is_empty_dir(int dirfd)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
@ -716,8 +720,10 @@ int is_empty_dir(int dirfd)
|
|||
struct dirent *de;
|
||||
|
||||
fdir = fdopendir(dirfd);
|
||||
if (!fdir)
|
||||
if (!fdir) {
|
||||
close_safe(&dirfd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((de = readdir(fdir))) {
|
||||
if (dir_dots(de))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue