diff options
author | Dunrong Huang <riegamaths@gmail.com> | 2012-09-05 21:26:22 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-09-12 15:50:09 +0200 |
commit | fe235a06e1e008dedd2ac3cc0a3a655169ce9b33 (patch) | |
tree | 481c9f0d6aa45692beacc381cbc2b8e5f755245c /block.c | |
parent | f0536bb848ad6eb2709a7dc675f261bd160c751b (diff) |
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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |