linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs: 2 quick coverity fixes
@ 2014-04-14 14:45 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:48 ` [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path Eric Sandeen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2014-04-14 14:45 UTC (permalink / raw)
  To: xfs-oss

The last round introduced 2 new warnings, trivial patches
to fix follow.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] xfs_logprint: Fix error handling in xlog_print_trans_efi
  2014-04-14 14:45 [PATCH 0/2] xfsprogs: 2 quick coverity fixes Eric Sandeen
@ 2014-04-14 14:46 ` 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
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2014-04-14 14:46 UTC (permalink / raw)
  To: xfs-oss, Mark Tinguely

A recent change to xlog_print_trans_efi() led to a leaked
"src_f" on this error return.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 928f60a..d482cf3 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -482,7 +482,7 @@ xlog_print_trans_efi(
 	uint src_len,
 	int continued)
 {
-    xfs_efi_log_format_t *src_f, *f;
+    xfs_efi_log_format_t *src_f, *f = NULL;
     uint		 dst_len;
     xfs_extent_t	 *ex;
     int			 i;
@@ -505,7 +505,8 @@ xlog_print_trans_efi(
 
     if (continued && src_len < core_size) {
 	printf(_("EFI: Not enough data to decode further\n"));
-	return 1;
+	error = 1;
+	goto error;
     }
 
     if ((f = (xfs_efi_log_format_t *)malloc(dst_len)) == NULL) {

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path
  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:48 ` Eric Sandeen
  2014-04-14 15:01   ` Mark Tinguely
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2014-04-14 14:48 UTC (permalink / raw)
  To: xfs-oss

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);
 }

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] xfs_logprint: Fix error handling in xlog_print_trans_efi
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Tinguely @ 2014-04-14 14:54 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On 04/14/14 09:46, Eric Sandeen wrote:
> A recent change to xlog_print_trans_efi() led to a leaked
> "src_f" on this error return.
>
> Signed-off-by: Eric Sandeen<sandeen@redhat.com>
> ---
>
> diff --git a/logprint/log_misc.c b/logprint/log_misc.c
> index 928f60a..d482cf3 100644
> --- a/logprint/log_misc.c
> +++ b/logprint/log_misc.c
> @@ -482,7 +482,7 @@ xlog_print_trans_efi(
>   	uint src_len,
>   	int continued)
>   {
> -    xfs_efi_log_format_t *src_f, *f;
> +    xfs_efi_log_format_t *src_f, *f = NULL;
>       uint		 dst_len;
>       xfs_extent_t	 *ex;
>       int			 i;
> @@ -505,7 +505,8 @@ xlog_print_trans_efi(
>
>       if (continued&&  src_len<  core_size) {
>   	printf(_("EFI: Not enough data to decode further\n"));
> -	return 1;
> +	error = 1;
> +	goto error;
>       }
>
>       if ((f = (xfs_efi_log_format_t *)malloc(dst_len)) == NULL) {
>

Looks good. Thank-you Eric and Coverity.

Reviewed-by: Mark Tinguely <tinguely@sgi.com>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Tinguely @ 2014-04-14 15:01 UTC (permalink / raw)
  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<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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-14 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).