From: Frediano Ziglio Date: Wed, 23 Oct 2019 12:26:51 +0000 (+0100) Subject: event_notifier: avoid dandling file descriptor in event_notifier_cleanup X-Git-Tag: v4.2.0-rc0~38^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=105e1023a855dd13fc15a8253fe6476f443e48aa;p=thirdparty%2Fqemu.git event_notifier: avoid dandling file descriptor in event_notifier_cleanup 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 Reviewed-by: Laurent Vivier Message-Id: <20191023122652.2999-2-fziglio@redhat.com> Signed-off-by: Laurent Vivier --- diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index 73c4046b587..00d93204f98 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; }