From: Dunrong Huang Date: Wed, 5 Sep 2012 13:26:22 +0000 (+0800) Subject: block: Don't forget to delete temporary file X-Git-Tag: v1.2.1~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9cf4af689b9c4d92857df11857912d5f9b865c9b;p=thirdparty%2Fqemu.git 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 Signed-off-by: Kevin Wolf (cherry picked from commit fe235a06e1e008dedd2ac3cc0a3a655169ce9b33) Signed-off-by: Michael Roth --- diff --git a/block.c b/block.c index c754353ac6b..e78039bd5a0 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;