aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-06 16:57:44 +0000
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-13 10:36:59 +0000
commit8d98734651a8a601980b6e57788f2ed6a4ea620a (patch)
treecb8c74cd622d5815df0565d4e50091af0ed58096 /block
parentdabdf394258aaa040fa0e754d6d05d7833542033 (diff)
downloadqemu-8d98734651a8a601980b6e57788f2ed6a4ea620a.zip
qemu-8d98734651a8a601980b6e57788f2ed6a4ea620a.tar.gz
qemu-8d98734651a8a601980b6e57788f2ed6a4ea620a.tar.bz2
vvfat: avoid leaking file descriptor in commit_one_file()
Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'block')
-rw-r--r--block/vvfat.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/vvfat.c b/block/vvfat.c
index eeffc4a..9ef21dd 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2218,6 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s,
}
if (offset > 0) {
if (lseek(fd, offset, SEEK_SET) != offset) {
+ close(fd);
g_free(cluster);
return -3;
}
@@ -2238,11 +2239,13 @@ static int commit_one_file(BDRVVVFATState* s,
(uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
if (ret < 0) {
+ close(fd);
g_free(cluster);
return ret;
}
if (write(fd, cluster, rest_size) < 0) {
+ close(fd);
g_free(cluster);
return -2;
}