summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorDunrong Huang <riegamaths@gmail.com>2012-09-05 21:26:22 +0800
committerKevin Wolf <kwolf@redhat.com>2012-09-12 15:50:09 +0200
commitfe235a06e1e008dedd2ac3cc0a3a655169ce9b33 (patch)
tree481c9f0d6aa45692beacc381cbc2b8e5f755245c /block.c
parentf0536bb848ad6eb2709a7dc675f261bd160c751b (diff)
downloadqemu-fe235a06e1e008dedd2ac3cc0a3a655169ce9b33.tar.gz
block: Don't forget to delete temporary file
The caller would not delete temporary file after failed get_tmp_filename(). Signed-off-by: Dunrong Huang <riegamaths@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block.c b/block.c
index c754353ac6..e78039bd5a 100644
--- a/block.c
+++ b/block.c
@@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size)
return -EOVERFLOW;
}
fd = mkstemp(filename);
- if (fd < 0 || close(fd)) {
+ if (fd < 0) {
+ return -errno;
+ }
+ if (close(fd) != 0) {
+ unlink(filename);
return -errno;
}
return 0;