From 8d98734651a8a601980b6e57788f2ed6a4ea620a Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Fri, 6 Jan 2012 16:57:44 +0000 Subject: vvfat: avoid leaking file descriptor in commit_one_file() Reported-by: Dr David Alan Gilbert Signed-off-by: Stefan Hajnoczi --- block/vvfat.c | 3 +++ 1 file changed, 3 insertions(+) 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; } -- cgit v1.1