From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 7F0DD29DF7 for ; Mon, 14 Apr 2014 10:02:00 -0500 (CDT) Message-ID: <534BF866.4020007@sgi.com> Date: Mon, 14 Apr 2014 10:01:58 -0500 From: Mark Tinguely MIME-Version: 1.0 Subject: Re: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path References: <534BF472.8030908@sandeen.net> <534BF53C.4000706@sandeen.net> In-Reply-To: <534BF53C.4000706@sandeen.net> List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: Eric Sandeen Cc: xfs-oss On 04/14/14 09:48, Eric Sandeen wrote: > My previous cleanups introduced this; in the case where > fd=open() failed, the out_fail: path would try to close(-1). > > Signed-off-by: Eric Sandeen > --- > > diff --git a/mkfs/proto.c b/mkfs/proto.c > index 308325b..5a47e27 100644 > --- a/mkfs/proto.c > +++ b/mkfs/proto.c > @@ -84,7 +84,8 @@ setup_proto( > return buf; > > out_fail: > - close(fd); > + if (fd>= 0) > + close(fd); > free(buf); > exit(1); > } > I would have bypassed the close with a new open error goto, but this does the trick as well. Reviewed-by: Mark Tinguely _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs