diff mbox series

[PULL,04/19] event_notifier: avoid dandling file descriptor in event_notifier_cleanup

Message ID 20191025083511.11463-5-laurent@vivier.eu
State New
Headers show
Series [PULL,01/19] qemu-options.hx: Update for reboot-timeout parameter | expand

Commit Message

Laurent Vivier Oct. 25, 2019, 8:34 a.m. UTC
From: Frediano Ziglio <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>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20191023122652.2999-2-fziglio@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 util/event_notifier-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 73c4046b5871..00d93204f988 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;
 }