qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: [PATCH for-5.1 3/3] file-posix: Fix leaked fd in raw_open_common() error path
Date: Fri, 17 Jul 2020 12:54:26 +0200	[thread overview]
Message-ID: <20200717105426.51134-4-kwolf@redhat.com> (raw)
In-Reply-To: <20200717105426.51134-1-kwolf@redhat.com>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/file-posix.c b/block/file-posix.c
index 659f780570..b2ed9d7eb2 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -749,6 +749,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
     }
     ret = 0;
 fail:
+    if (ret < 0 && s->fd != -1) {
+        qemu_close(s->fd);
+    }
     if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
         unlink(filename);
     }
-- 
2.25.4



  parent reply	other threads:[~2020-07-17 10:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 10:54 [PATCH for-5.1 0/3] file-posix: Fix check_hdev_writable() with auto-read-only Kevin Wolf
2020-07-17 10:54 ` [PATCH for-5.1 1/3] file-posix: Move check_hdev_writable() up Kevin Wolf
2020-07-17 11:45   ` Max Reitz
2020-07-17 10:54 ` [PATCH for-5.1 2/3] file-posix: Fix check_hdev_writable() with auto-read-only Kevin Wolf
2020-07-17 11:50   ` Max Reitz
2020-07-17 10:54 ` Kevin Wolf [this message]
2020-07-17 11:55   ` [PATCH for-5.1 3/3] file-posix: Fix leaked fd in raw_open_common() error path Max Reitz
2020-07-17 11:49 ` [PATCH for-5.1 0/3] file-posix: Fix check_hdev_writable() with auto-read-only no-reply

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=20200717105426.51134-4-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).