qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 11/11] block: Don't forget to delete temporary file
Date: Fri, 14 Sep 2012 14:39:12 +0200	[thread overview]
Message-ID: <1347626352-6023-12-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1347626352-6023-1-git-send-email-kwolf@redhat.com>

From: Dunrong Huang <riegamaths@gmail.com>

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>
---
 block.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index c754353..e78039b 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;
-- 
1.7.6.5

  parent reply	other threads:[~2012-09-14 12:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14 12:39 [Qemu-devel] [PULL 00/11] Block patches Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 01/11] sheepdog: fix savevm and loadvm Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 02/11] ATAPI: STARTSTOPUNIT only eject/load media if powercondition is 0 Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 03/11] ide: Fix error messages from static code analysis (no real error) Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 04/11] block/curl: Fix wrong free statement Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 05/11] vdi: Fix warning from clang Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 06/11] block: fix block tray status Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 07/11] ahci: properly reset PxCMD on HBA reset Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 08/11] qapi: Add SnapshotInfo and ImageInfo Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 09/11] qemu-img: Add json output option to the info command Kevin Wolf
2012-09-14 12:39 ` [Qemu-devel] [PATCH 10/11] Don't require encryption password for 'qemu-img info' command Kevin Wolf
2012-09-14 12:39 ` Kevin Wolf [this message]
2012-09-17 18:19 ` [Qemu-devel] [PULL 00/11] Block patches Anthony Liguori
2012-09-18 17:49 ` Michael Tokarev
2012-09-19  8:42   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347626352-6023-12-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).