From: Mark Tinguely <tinguely@sgi.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path
Date: Mon, 14 Apr 2014 10:01:58 -0500 [thread overview]
Message-ID: <534BF866.4020007@sgi.com> (raw)
In-Reply-To: <534BF53C.4000706@sandeen.net>
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<sandeen@redhat.com>
> ---
>
> 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 <tinguely@sgi.com>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2014-04-14 15:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-14 14:45 [PATCH 0/2] xfsprogs: 2 quick coverity fixes Eric Sandeen
2014-04-14 14:46 ` [PATCH 1/2] xfs_logprint: Fix error handling in xlog_print_trans_efi Eric Sandeen
2014-04-14 14:54 ` Mark Tinguely
2014-04-14 14:48 ` [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path Eric Sandeen
2014-04-14 15:01 ` Mark Tinguely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=534BF866.4020007@sgi.com \
--to=tinguely@sgi.com \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).