xfs: fix uninitialized variables in xrep_calc_ag_resblks
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Mar 2021 16:51:51 +0000 (09:51 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 25 Mar 2021 23:47:49 +0000 (16:47 -0700)
If we can't read the AGF header, we never actually set a value for
freelen and usedlen.  These two variables are used to make the worst
case estimate of btree size, so it's safe to set them to the AG size as
a fallback.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/repair.c

index 25e86c71e7b9a56a141361e15a17d2229bea7318..61bc43418a2aa698cf11e4224d48c5edece79884 100644 (file)
@@ -207,7 +207,11 @@ xrep_calc_ag_resblks(
 
        /* Now grab the block counters from the AGF. */
        error = xfs_alloc_read_agf(mp, NULL, sm->sm_agno, 0, &bp);
-       if (!error) {
+       if (error) {
+               aglen = xfs_ag_block_count(mp, sm->sm_agno);
+               freelen = aglen;
+               usedlen = aglen;
+       } else {
                struct xfs_agf  *agf = bp->b_addr;
 
                aglen = be32_to_cpu(agf->agf_length);