Commit 7e50b256 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Pavel Emelyanov

criu: fix leaks detected by coverity scan

1) fix sfle memory leak on get_fle_for_scm error
2) fix gfd open descriptor leak on get_fle_for_scm error
3-6) fix buf memory leak on read and pwrite errors
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
parent 39cf3060
...@@ -166,7 +166,6 @@ static int copy_chunk_from_file(int fd, int img, off_t off, size_t len) ...@@ -166,7 +166,6 @@ static int copy_chunk_from_file(int fd, int img, off_t off, size_t len)
} }
xfree(buf); xfree(buf);
return 0; return 0;
} }
...@@ -231,7 +230,6 @@ static int copy_chunk_to_file(int img, int fd, off_t off, size_t len) ...@@ -231,7 +230,6 @@ static int copy_chunk_to_file(int img, int fd, off_t off, size_t len)
} }
xfree(buf); xfree(buf);
return 0; return 0;
} }
...@@ -268,6 +266,7 @@ static int mkreg_ghost(char *path, GhostFileEntry *gfe, struct cr_img *img) ...@@ -268,6 +266,7 @@ static int mkreg_ghost(char *path, GhostFileEntry *gfe, struct cr_img *img)
if (gfe->chunks) { if (gfe->chunks) {
if (!gfe->has_size) { if (!gfe->has_size) {
pr_err("Corrupted ghost image -> no size\n"); pr_err("Corrupted ghost image -> no size\n");
close(gfd);
return -1; return -1;
} }
......
...@@ -1055,6 +1055,7 @@ int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids) ...@@ -1055,6 +1055,7 @@ int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids)
sfle->fle = get_fle_for_task(tgt, owner, false); sfle->fle = get_fle_for_task(tgt, owner, false);
if (!sfle->fle) { if (!sfle->fle) {
pr_err("Can't request new fle for scm\n"); pr_err("Can't request new fle for scm\n");
xfree(sfle);
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment