xfsprogs: 2 quick coverity fixes
cover xfsprogs: 2 quick coverity fixes
The last round introduced 2 new warnings, trivial patches to fix follow.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 xfs_logprint: Fix error handling in xlog_print_trans_efi
A recent change to xlog_print_trans_efi() led to a leaked "src_f" on this error return.
---
logprint/log_misc.c +3 -2
@@ -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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/2] xfs_logprint: Fix error handling in xlog_print_trans_efi
Quoted 21 lines · Eric Sandeen
A recent change to
xlog_print_trans_efi()led to a leaked "src_f" on this error return.Signed-off-by Eric Sandeen<[email protected]>---
logprint/log_misc.c +1
-1@@ -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;
logprint/log_misc.c xlog_print_trans_efi( · line 512
Quoted 9 lines
logprint/log_misc.c +2
-1@@ -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.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path
In reply to Eric SandeenMy previous cleanups introduced this; in the case where fd=open() failed, the out_fail: path would try to close(-1).
---
mkfs/proto.c +2 -1
@@ -84,7 +84,8 @@ setup_proto(return buf; out_fail: -close (fd); +if (fd >=0 ) +close (fd);free (buf);exit (1 ); }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Mark Tinguely
Reviewed-byRe: [PATCH 2/2] mkfs.xfs: prevent close(-1) on protofile error path
Quoted 12 lines · Eric Sandeen
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<[email protected]>---
mkfs/proto.c +0
-0
mkfs/proto.c setup_proto( · line 91
Quoted 9 lines
mkfs/proto.c +2
-1@@ -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.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs