From fe235a06e1e008dedd2ac3cc0a3a655169ce9b33 Mon Sep 17 00:00:00 2001 From: Dunrong Huang Date: Wed, 5 Sep 2012 21:26:22 +0800 Subject: 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 --- block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'block.c') 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; -- cgit v1.2.3