From patchwork Fri Oct 25 08:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1183909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46zyMJ0TTsz9sPL for ; Fri, 25 Oct 2019 19:43:56 +1100 (AEDT) Received: from localhost ([::1]:57614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNvCL-0003vE-BI for incoming@patchwork.ozlabs.org; Fri, 25 Oct 2019 04:43:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49790) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNv4w-0000eG-7a for qemu-devel@nongnu.org; Fri, 25 Oct 2019 04:36:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNv4v-0007oE-78 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 04:36:14 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:39421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNv4l-0007fP-Jw; Fri, 25 Oct 2019 04:36:05 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MGzI3-1iAOHL1E8J-00E7YF; Fri, 25 Oct 2019 10:35:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/19] event_notifier: avoid dandling file descriptor in event_notifier_cleanup Date: Fri, 25 Oct 2019 10:34:56 +0200 Message-Id: <20191025083511.11463-5-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191025083511.11463-1-laurent@vivier.eu> References: <20191025083511.11463-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:/ygMbVZUdrFShG2v+IwnlPx6NIe+igwbNnW32CPAFZuGdtiUZh9 0Ag7mN+G3qOA/JlMXTSSzZMY2YZxxMu+jxcdUV3RBC7q7YF4hZCrD2ewOCsG35HyemMQOH0 s0OumAT5NnUORhCIcj+oZsgEWy/CdihNGmfwGmsa+EE/XjFUElfWapjzoTvtvcHW/qPABLp 6f9lJd4xJqi8TuaIrEc1w== X-UI-Out-Filterresults: notjunk:1; V03:K0:5TrCoAdjS+w=:JrwOcPzSsGryCaoDQey2WN BPSyYWdhIqoa2zPIH+8m0tRxMWYzgJeURfgN80r3PI55IGpPXSaQVKckmk2aw2FakezM1KNvR iaL4KW4/ESiWbew9xuUkGWBIlNsDtXFo1rUm5ETB2o+zwg2WJS5Y7fpnBvNBof5p2ntYqYcYH 2oUdz0ZC08JmvE0Uorr9MKPnAgyVhOe51awoiAx69gQ+jZtduR2RARiNL3+WAdA6TvFPlmtEE zScXw3SnBZcSq2yngSGSz5CojOq+DjWNSYx64PoY2OaZxilz77wwNxaLbWQITVscS8ij2I0zO RZV4+/fft28sCQ0g7echHzRsio77eFLJ21ZcAungNlpoiRYe665tM9yi/0IsEbBY7+R3qCLAl hBOHSDzhpnzItNTYSUrE00CK6sMb5XJfSKZAOCifukifEcQpXnsMYP0fZeT42VtLFAHeThLEf biJTxCnF43gHscNjwlkVZCGtQ5ZXXEHX8gJGsIHQZckdS9cHZYUKXBgSgmKAkJ4eiDd6yLpsY O6ozRs2rtdX6ZZoJe/4W0Zk2VbSCErwPOtzKMvu5NcfgBIozzzwftvChf54tfL5Be98lH5RNJ U/kcZNIO4iD+lUokltU4qnXR+TuC5jgAc9mz3j+vZ5uHKvCbYsqFIIWBeSIEOI5q4dyciz7Av rUG1DPiITW5Z6SsUwNyr75tW7wiRQj/vTZEybtmCWRQB1RfT0+FkHheGDOwvSuZuytzHOGbwy V/iRz6zkE/7JTv/WY4IUYXcBnzqVPXcWPyCs5siSV/9yjkTqtiFzSOUht7EmqvES4tkATwg7T pSyk4iZJtGvt1Hx0rJOXL4UeBAOJKlbnvXC65JhX+VkTjHJ/4wIn7N9+IdfU/KeRGF1l7wTlQ dQvEq5Ok5NvynbHdU6tw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , "Michael S. Tsirkin" , Michael Tokarev , "Edgar E. Iglesias" , qemu-block@nongnu.org, qemu-trivial@nongnu.org, Helge Deller , =?utf-8?q?Herv?= =?utf-8?q?=C3=A9_Poussineau?= , Joel Stanley , David Gibson , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , Alistair Francis , qemu-arm@nongnu.org, =?utf-8?b?Q8OpZHJpYyBM?= =?utf-8?q?e_Goater?= , Stefan Hajnoczi , Igor Mammedov , Richard Henderson , Andrew Jeffery , Laurent Vivier , Aleksandar Rikalo , qemu-ppc@nongnu.org, Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno , Frediano Ziglio Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frediano Ziglio 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 --- 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 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; }