From: Eric Sandeen Date: Thu, 1 May 2014 23:32:59 +0000 (+1000) Subject: mkfs.xfs: prevent close(-1) on protofile error path X-Git-Tag: v3.2.0-rc2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aabc02b30ac664395aaaed5dd626b5813986291e;p=thirdparty%2Fxfsprogs-dev.git mkfs.xfs: prevent close(-1) on protofile error path 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 Reviewed-by: Mark Tinguely Signed-off-by: Dave Chinner --- diff --git a/mkfs/proto.c b/mkfs/proto.c index 308325be2..5a47e27c0 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); }