mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
dabdf39425
commit
8d98734651
1 changed files with 3 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue