From: Carlos Maiolino Date: Fri, 27 Jul 2018 22:03:33 +0000 (-0500) Subject: xfs: Initialize variables in xfs_alloc_get_rec before using them X-Git-Tag: v4.18.0-rc1~21^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c25e430563281b8efc45d7877f40c8e7cdff80ee;p=thirdparty%2Fxfsprogs-dev.git xfs: Initialize variables in xfs_alloc_get_rec before using them Source kernel commit: 9991274fddb9fd4413cb166763cf7368f5086419 Make sure we initialize *bno and *len, before jumping to out_bad_rec label, and risk calling xfs_warn() with uninitialized variables. Coverity: 100898 Coverity: 1437081 Coverity: 1437129 Coverity: 1437191 Coverity: 1437201 Coverity: 1437212 Coverity: 1437341 Signed-off-by: Carlos Maiolino Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 20b714121..5ead56d29 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -219,12 +219,13 @@ xfs_alloc_get_rec( error = xfs_btree_get_rec(cur, &rec, stat); if (error || !(*stat)) return error; - if (rec->alloc.ar_blockcount == 0) - goto out_bad_rec; *bno = be32_to_cpu(rec->alloc.ar_startblock); *len = be32_to_cpu(rec->alloc.ar_blockcount); + if (*len == 0) + goto out_bad_rec; + /* check for valid extent range, including overflow */ if (!xfs_verify_agbno(mp, agno, *bno)) goto out_bad_rec;