qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frediano Ziglio <fziglio@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>, Laurent Vivier <laurent@vivier.eu>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	Frediano Ziglio <fziglio@redhat.com>
Subject: [PATCH 2/3] event_notifier: avoid dandling file descriptor in event_notifier_cleanup
Date: Wed, 23 Oct 2019 13:26:51 +0100	[thread overview]
Message-ID: <20191023122652.2999-2-fziglio@redhat.com> (raw)
In-Reply-To: <20191023122652.2999-1-fziglio@redhat.com>

If rfd is equal to wfd the file descriptor is closed but
rfd will still have the closed value.
The EventNotifier structure should not be used again after calling
event_notifier_cleanup or should be initialized again but make
sure to not have dandling file descriptors around.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 util/event_notifier-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 73c4046b58..00d93204f9 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -80,8 +80,8 @@ void event_notifier_cleanup(EventNotifier *e)
 {
     if (e->rfd != e->wfd) {
         close(e->rfd);
-        e->rfd = -1;
     }
+    e->rfd = -1;
     close(e->wfd);
     e->wfd = -1;
 }
-- 
2.21.0



  reply	other threads:[~2019-10-23 12:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 12:26 [PATCH 1/3] util/async: avoid useless cast Frediano Ziglio
2019-10-23 12:26 ` Frediano Ziglio [this message]
2019-10-23 13:42   ` [PATCH 2/3] event_notifier: avoid dandling file descriptor in event_notifier_cleanup Laurent Vivier
2019-10-24 17:27   ` Laurent Vivier
2019-10-23 12:26 ` [PATCH 3/3] qemu-timer: reuse MIN macro in qemu_timeout_ns_to_ms Frediano Ziglio
2019-10-23 13:42   ` Laurent Vivier
2019-10-23 14:12     ` Eric Blake
2019-10-23 14:15       ` Frediano Ziglio
2019-10-23 14:23         ` Eric Blake
2019-10-23 14:45           ` Laurent Vivier
2019-10-23 14:51             ` Eric Blake
2019-10-23 14:58               ` Laurent Vivier
2019-10-24 17:31   ` Laurent Vivier
2019-10-24 18:03     ` Eric Blake
2019-10-24 18:11       ` Laurent Vivier
2019-10-24 20:55         ` Eric Blake
2019-10-23 13:44 ` [PATCH 1/3] util/async: avoid useless cast Laurent Vivier
2019-10-24 17:26 ` Laurent Vivier

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=20191023122652.2999-2-fziglio@redhat.com \
    --to=fziglio@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).