From patchwork Sun May 11 21:28:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 347835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 24F22140083 for ; Mon, 12 May 2014 07:32:02 +1000 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4BLVvZi029399 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 May 2014 21:31:58 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4BLVvIK017572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 May 2014 21:31:57 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WjbId-00048n-UK; Sun, 11 May 2014 14:28:47 -0700 Received: from ucsinet22.oracle.com ([156.151.31.94]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WjbIZ-00048H-0R for fedfs-utils-devel@oss.oracle.com; Sun, 11 May 2014 14:28:43 -0700 Received: from aserp1030.oracle.com (aserp1030.oracle.com [141.146.126.68]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s4BLSgWE024215 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 11 May 2014 21:28:42 GMT Received: from mail-ie0-f174.google.com (mail-ie0-f174.google.com [209.85.223.174]) by aserp1030.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4BLSfaq025646 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 11 May 2014 21:28:41 GMT Authentication-Results: aserp1030.oracle.com; dkim=pass reason="2048-bit key" header.d=gmail.com header.i=@gmail.com header.b=xm+b1F9t Received: by mail-ie0-f174.google.com with SMTP id at1so2796402iec.33 for ; Sun, 11 May 2014 14:28:41 -0700 (PDT) X-Received: by 10.50.92.98 with SMTP id cl2mr36127790igb.14.1399843721006; Sun, 11 May 2014 14:28:41 -0700 (PDT) Received: from seurat.1015granger.net ([2604:8800:100:81fc:20c:29ff:fe44:ec31]) by mx.google.com with ESMTPSA id u2sm16888165igs.10.2014.05.11.14.28.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 May 2014 14:28:40 -0700 (PDT) To: fedfs-utils-devel@oss.oracle.com From: Chuck Lever Date: Sun, 11 May 2014 17:28:39 -0400 Message-ID: <20140511212839.13852.6354.stgit@seurat.1015granger.net> In-Reply-To: <20140511212416.13852.92639.stgit@seurat.1015granger.net> References: <20140511212416.13852.92639.stgit@seurat.1015granger.net> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=209.85.223.174 ct-class=R5 ct-vol1=-98 ct-vol2=8 ct-vol3=7 ct-risk=51 ct-spam1=82 ct-spam2=7 ct-bulk=6 rcpts=1 size=726 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=IYq+Bwaa c=1 sm=1 tr=0 a=MAC9HxUk7fez6cFlCIg1Bw==:117 a=dzsqy3y4QnMA:10 a=-CvCuborIeoA:10 a=dPGociXpb70A:10 a=IkcTkHD0fZMA:10 a=xqWC_Br6kY4A:10 a=yPCof4ZbAAAA:8 a=Lb1rMZzfAAAA:8 a=1XWaLZrsAAAA:8 a=_dn1C1ooOJlbQ2Kyj38A:9 a=QEXdDO 2ut3YA:10 a=7DSvI1NPTFQA:10 X-Sendmail-CT-RefID: str=0001.0A090205.536FEB8A.0006, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Sendmail-CT-Classification: not spam Subject: [fedfs-utils] [PATCH 04/17] libjunction: Fix file descriptor leak in junction_get_mode() X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] A second close(2) is used to preserve the value of errno when reporting the error via xlog(). Signed-off-by: Chuck Lever --- src/libjunction/junction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libjunction/junction.c b/src/libjunction/junction.c index 9d9a266..7b7b2e4 100644 --- a/src/libjunction/junction.c +++ b/src/libjunction/junction.c @@ -394,9 +394,9 @@ junction_get_mode(const char *pathname, mode_t *mode) if (fstat(fd, &stb) == -1) { xlog(D_GENERAL, "%s: failed to stat %s: %m", __func__, pathname); + (void)close(fd); return FEDFS_ERR_ACCESS; } - (void)close(fd); xlog(D_CALL, "%s: pathname %s has mode %o",