From: Darrick J. Wong Date: Mon, 31 Jul 2017 20:08:12 +0000 (-0500) Subject: xfs: set firstfsb to NULLFSBLOCK before feeding it to _bmapi_write X-Git-Tag: v4.13.0-rc1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66d19ae11974b6a9e6e49b1277993af98d6a98df;p=thirdparty%2Fxfsprogs-dev.git xfs: set firstfsb to NULLFSBLOCK before feeding it to _bmapi_write Source kernel commit: 4c1a67bd3606540b9b42caff34a1d5cd94b1cf65 We must initialize the firstfsb parameter to _bmapi_write so that it doesn't incorrectly treat stack garbage as a restriction on which AGs it can search for free space. Fixes-coverity-id: 1402025 Fixes-coverity-id: 1415167 Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index d44a4e9e7..d11e4d656 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -6490,6 +6490,15 @@ xfs_bmap_finish_one( xfs_fsblock_t firstfsb; int error = 0; + /* + * firstfsb is tied to the transaction lifetime and is used to + * ensure correct AG locking order and schedule work item + * continuations. XFS_BUI_MAX_FAST_EXTENTS (== 1) restricts us + * to only making one bmap call per transaction, so it should + * be safe to have it as a local variable here. + */ + firstfsb = NULLFSBLOCK; + trace_xfs_bmap_deferred(tp->t_mountp, XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),