diff mbox

[6/8] xfs: fix uninitialized field in rtbitmap fsmap backend

Message ID 20180622064118.GF27254@infradead.org (mailing list archive)
State Superseded
Headers show

Commit Message

Christoph Hellwig June 22, 2018, 6:41 a.m. UTC
On Thu, Jun 21, 2018 at 11:31:41AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Initialize the extent count field of the high key so that when we use
> the high key to synthesize an 'unknown owner' record (i.e. used space
> record) at the end of the queried range we have a field with which to
> compute rm_blockcount.  This is not strictly necessary because the
> synthesizer never uses the rm_blockcount field, but we can shut up the
> static code analysis anyway.
> 
> Coverity-id: 1437358
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

I'd rather ensure the structs are entirely zeroed to start with, e.g.:

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Darrick J. Wong June 22, 2018, 6:47 a.m. UTC | #1
On Thu, Jun 21, 2018 at 11:41:18PM -0700, Christoph Hellwig wrote:
> On Thu, Jun 21, 2018 at 11:31:41AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Initialize the extent count field of the high key so that when we use
> > the high key to synthesize an 'unknown owner' record (i.e. used space
> > record) at the end of the queried range we have a field with which to
> > compute rm_blockcount.  This is not strictly necessary because the
> > synthesizer never uses the rm_blockcount field, but we can shut up the
> > static code analysis anyway.
> > 
> > Coverity-id: 1437358
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> I'd rather ensure the structs are entirely zeroed to start with, e.g.:
> 
> diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
> index 0299febece9c..21bbdee451a6 100644
> --- a/fs/xfs/xfs_fsmap.c
> +++ b/fs/xfs/xfs_fsmap.c
> @@ -527,8 +527,8 @@ xfs_getfsmap_rtdev_rtbitmap_query(
>  	struct xfs_trans		*tp,
>  	struct xfs_getfsmap_info	*info)
>  {
> -	struct xfs_rtalloc_rec		alow;
> -	struct xfs_rtalloc_rec		ahigh;
> +	struct xfs_rtalloc_rec		alow = { 0, };
> +	struct xfs_rtalloc_rec		ahigh = { 0, };

Looks reasonable, I'll give it a spin overnight.

--D

>  	int				error;
>  
>  	xfs_ilock(tp->t_mountp->m_rbmip, XFS_ILOCK_SHARED);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 0299febece9c..21bbdee451a6 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -527,8 +527,8 @@  xfs_getfsmap_rtdev_rtbitmap_query(
 	struct xfs_trans		*tp,
 	struct xfs_getfsmap_info	*info)
 {
-	struct xfs_rtalloc_rec		alow;
-	struct xfs_rtalloc_rec		ahigh;
+	struct xfs_rtalloc_rec		alow = { 0, };
+	struct xfs_rtalloc_rec		ahigh = { 0, };
 	int				error;
 
 	xfs_ilock(tp->t_mountp->m_rbmip, XFS_ILOCK_SHARED);