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
@ -2218,6 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s,
|
|||||||
}
|
}
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
if (lseek(fd, offset, SEEK_SET) != offset) {
|
if (lseek(fd, offset, SEEK_SET) != offset) {
|
||||||
|
close(fd);
|
||||||
g_free(cluster);
|
g_free(cluster);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -2238,11 +2239,13 @@ static int commit_one_file(BDRVVVFATState* s,
|
|||||||
(uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
|
(uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
close(fd);
|
||||||
g_free(cluster);
|
g_free(cluster);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, cluster, rest_size) < 0) {
|
if (write(fd, cluster, rest_size) < 0) {
|
||||||
|
close(fd);
|
||||||
g_free(cluster);
|
g_free(cluster);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user