[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [qemu-xen-unstable] block-vvfat: fix memory/handle leaks in commit_one_file()
commit b8b1c0d888c16ca2130c543122c69e9de5ef53c6 Author: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx> AuthorDate: Fri Mar 7 16:44:33 2014 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Fri Oct 16 16:52:06 2015 +0100 block-vvfat: fix memory/handle leaks in commit_one_file() Some handles and memory in commit_one_file are going to be leaked if certain function calls failed. Signed-off-by: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx> Coverity-IDs: 1055918 1055919 Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- block-vvfat.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/block-vvfat.c b/block-vvfat.c index 345d7be..ec3363c 100644 --- a/block-vvfat.c +++ b/block-vvfat.c @@ -2229,11 +2229,15 @@ static int commit_one_file(BDRVVVFATState* s, if (fd < 0) { fprintf(stderr, "Could not open %s... (%s, %d)\n", mapping->path, strerror(errno), errno); + qemu_free(cluster); return fd; } if (offset > 0) - if (lseek(fd, offset, SEEK_SET) != offset) + if (lseek(fd, offset, SEEK_SET) != offset) { + close(fd); + qemu_free(cluster); return -3; + } while (offset < size) { uint32_t c1; @@ -2249,11 +2253,17 @@ static int commit_one_file(BDRVVVFATState* s, ret = vvfat_read(s->bs, cluster2sector(s, c), (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200); - if (ret < 0) + if (ret < 0) { + close(fd); + qemu_free(cluster); return ret; + } - if (qemu_write_ok(fd, cluster, rest_size) < 0) + if (qemu_write_ok(fd, cluster, rest_size) < 0) { + close(fd); + qemu_free(cluster); return -2; + } offset += rest_size; c = c1; @@ -2261,6 +2271,7 @@ static int commit_one_file(BDRVVVFATState* s, ftruncate(fd, size); close(fd); + qemu_free(cluster); return commit_mappings(s, first_cluster, dir_index); } -- generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |