[CRIU] [PATCH] inotify: Don't forget to close opened files on error path
Cyrill Gorcunov
gorcunov at openvz.org
Thu Nov 29 08:16:20 EST 2012
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
inotify.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/inotify.c b/inotify.c
index 46b1797..d410ce3 100644
--- a/inotify.c
+++ b/inotify.c
@@ -111,8 +111,8 @@ int dump_inotify(struct fd_parms *p, int lfd, const struct cr_fdset *set)
static int restore_one_inotify(int inotify_fd, InotifyWdEntry *iwe)
{
char path[32];
- int mntfd, ret = -1;
- int wd, target;
+ int mntfd = -1, ret = -1;
+ int wd, target = -1;
fh_t handle = { };
/* syscall waits for strict structure here */
@@ -133,7 +133,7 @@ static int restore_one_inotify(int inotify_fd, InotifyWdEntry *iwe)
if (target < 0) {
pr_perror("Can't open file handle for 0x%08x:0x%016lx",
iwe->s_dev, iwe->i_ino);
- return -1;
+ goto err;
}
snprintf(path, sizeof(path), "/proc/self/fd/%d", target);
@@ -162,9 +162,9 @@ static int restore_one_inotify(int inotify_fd, InotifyWdEntry *iwe)
inotify_rm_watch(inotify_fd, wd);
}
- close(mntfd);
- close(target);
-
+err:
+ close_safe(&mntfd);
+ close_safe(&target);
return ret;
}
--
1.7.7.6
More information about the CRIU
mailing list