From patchwork Tue Jul 7 20:10:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 39948 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 68DFF3857010; Tue, 7 Jul 2020 20:10:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id C893D3857C53 for ; Tue, 7 Jul 2020 20:10:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C893D3857C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id EED119CF; Tue, 7 Jul 2020 22:10:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PoSunOuSh_f4; Tue, 7 Jul 2020 22:10:44 +0200 (CEST) Received: from function (lfbn-bor-1-797-11.w86-234.abo.wanadoo.fr [86.234.239.11]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 5BC55865; Tue, 7 Jul 2020 22:10:44 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1jstvP-003U3y-Lr; Tue, 07 Jul 2020 22:10:43 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd, commited] hurd: Evaluate fd before entering the critical section Date: Tue, 7 Jul 2020 22:10:43 +0200 Message-Id: <20200707201043.830505-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * sysdeps/hurd/include/hurd/fd.h (HURD_FD_PORT_USE_CANCEL): Evaluate fd before calling _hurd_critical_section_lock. --- sysdeps/hurd/include/hurd/fd.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysdeps/hurd/include/hurd/fd.h b/sysdeps/hurd/include/hurd/fd.h index 3a6cdc7f36..1985b6fbb2 100644 --- a/sysdeps/hurd/include/hurd/fd.h +++ b/sysdeps/hurd/include/hurd/fd.h @@ -20,10 +20,11 @@ extern void _hurd_fd_port_use_cleanup (void *arg); /* Like HURD_FD_PORT_USE, but cleans fd on cancel. */ #define HURD_FD_PORT_USE_CANCEL(fd, expr) \ ({ error_t __result; \ - void *__crit = _hurd_critical_section_lock (); \ struct _hurd_fd_port_use_data __d; \ io_t port, ctty; \ + void *__crit; \ __d.d = (fd); \ + __crit = _hurd_critical_section_lock (); \ __spin_lock (&__d.d->port.lock); \ if (__d.d->port.port == MACH_PORT_NULL) \ { \