public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Fwd: New Defects reported by Coverity Scan for xfsprogs
       [not found] <5362fbfc78ad5_2dbacf387045986@209.249.196.67.mail>
@ 2014-05-06  9:03 ` Jeff Liu
  2014-05-06  9:16   ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Liu @ 2014-05-06  9:03 UTC (permalink / raw)
  To: xfs@oss.sgi.com

Hi Folks,

I'm not sure if someone else has also noticed the following reports from Coverity.


-------- Original Message --------
Subject: New Defects reported by Coverity Scan for xfsprogs
Date: Thu, 01 May 2014 18:59:24 -0700
From: scan-admin@coverity.com


Hi,


Please find the latest report on new defect(s) introduced to xfsprogs found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 996972:  Out-of-bounds access  (OVERRUN)
/libxfs/xfs_btree.c: 2641 in xfs_btree_new_root()


________________________________________________________________________________________________________
*** CID 996972:  Out-of-bounds access  (OVERRUN)
/libxfs/xfs_btree.c: 2641 in xfs_btree_new_root()
2635     	/* Allocate the new block. If we can't do it, we're toast. Give up. */
2636     	error = cur->bc_ops->alloc_block(cur, &rptr, &lptr, 1, stat);
2637     	if (error)
2638     		goto error0;
2639     	if (*stat == 0)
2640     		goto out0;
>>>     CID 996972:  Out-of-bounds access  (OVERRUN)
>>>     Jumping to case "XFS_BTNUM_MAX".
2641     	XFS_BTREE_STATS_INC(cur, alloc);
2642     
2643     	/* Set up the new block. */
2644     	error = xfs_btree_get_buf_block(cur, &lptr, 0, &new, &nbp);
2645     	if (error)
2646     		goto error0;


It seems like a false alarm, but maybe we can just remove the out0 label as below?

From: Jie Liu <jeff.liu@oracle.com>
Subject: xfs: get rid of out0 goto label from xfs_btree_new_root

Get rid of the useless out0 goto label and return 0 directly in case
of falling to alloate the new block.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/xfs/xfs_btree.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 182bac2..f162dc9 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -2653,8 +2653,11 @@ xfs_btree_new_root(
 	error = cur->bc_ops->alloc_block(cur, &rptr, &lptr, stat);
 	if (error)
 		goto error0;
-	if (*stat == 0)
-		goto out0;
+	if (*stat == 0) {
+		XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
+		return 0;
+	}
+
 	XFS_BTREE_STATS_INC(cur, alloc);
 
 	/* Set up the new block. */
@@ -2743,10 +2746,6 @@ xfs_btree_new_root(
 error0:
 	XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
 	return error;
-out0:
-	XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
-	*stat = 0;
-	return 0;
 }
 
 STATIC int
-- 
1.8.3.2


Cheers,
-Jeff

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

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

* Re: Fwd: New Defects reported by Coverity Scan for xfsprogs
  2014-05-06  9:03 ` Fwd: New Defects reported by Coverity Scan for xfsprogs Jeff Liu
@ 2014-05-06  9:16   ` Dave Chinner
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2014-05-06  9:16 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs@oss.sgi.com

On Tue, May 06, 2014 at 05:03:52PM +0800, Jeff Liu wrote:
> Hi Folks,
> 
> I'm not sure if someone else has also noticed the following reports from Coverity.

yup, saw it - it not a regression from a recent checkin, so it must
some new check they've added to Coverity. However, i ignored it
because it looked completely bogus....

> It seems like a false alarm, but maybe we can just remove the out0 label as below?

Yup, it must be getting confused with the assignment of *stat = 0
after checking that it is already zero...

> From: Jie Liu <jeff.liu@oracle.com>
> Subject: xfs: get rid of out0 goto label from xfs_btree_new_root
> 
> Get rid of the useless out0 goto label and return 0 directly in case
> of falling to alloate the new block.
> 
> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
> ---
>  fs/xfs/xfs_btree.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
> index 182bac2..f162dc9 100644
> --- a/fs/xfs/xfs_btree.c
> +++ b/fs/xfs/xfs_btree.c
> @@ -2653,8 +2653,11 @@ xfs_btree_new_root(
>  	error = cur->bc_ops->alloc_block(cur, &rptr, &lptr, stat);
>  	if (error)
>  		goto error0;
> -	if (*stat == 0)
> -		goto out0;
> +	if (*stat == 0) {
> +		XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
> +		return 0;
> +	}
> +
>  	XFS_BTREE_STATS_INC(cur, alloc);
>  
>  	/* Set up the new block. */
> @@ -2743,10 +2746,6 @@ xfs_btree_new_root(
>  error0:
>  	XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
>  	return error;
> -out0:
> -	XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
> -	*stat = 0;
> -	return 0;
>  }

Looks fine. It's not obviously a problem, so I'll queue it up for
after then 3.2.0 release.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

end of thread, other threads:[~2014-05-06  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5362fbfc78ad5_2dbacf387045986@209.249.196.67.mail>
2014-05-06  9:03 ` Fwd: New Defects reported by Coverity Scan for xfsprogs Jeff Liu
2014-05-06  9:16   ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox