[CRIU] [PATCH] criu: fix leaks detected by coverity scan part 2
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri Feb 2 11:41:01 MSK 2018
*** CID 179043: (USE_AFTER_FREE)
close bfd fd safe so that we won't have double close
*** CID 179041: Resource leaks (RESOURCE_LEAK)
don't forget to close fd on error
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/bfd.c | 2 +-
criu/kerndat.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/criu/bfd.c b/criu/bfd.c
index 4d54543c7..3c9eb51cd 100644
--- a/criu/bfd.c
+++ b/criu/bfd.c
@@ -91,7 +91,7 @@ static void buf_put(struct xbuf *xb)
static int bfdopen(struct bfd *f, bool writable)
{
if (buf_get(&f->b)) {
- close(f->fd);
+ close_safe(&f->fd);
return -1;
}
diff --git a/criu/kerndat.c b/criu/kerndat.c
index 68abd6180..ff1980bcc 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -808,6 +808,7 @@ static int kerndat_try_load_cache(void)
ret = read(fd, &kdat, sizeof(kdat));
if (ret < 0) {
pr_perror("Can't read kdat cache");
+ close(fd);
return -1;
}
--
2.14.3
More information about the CRIU
mailing list