From: Darrick J. Wong Date: Mon, 31 Jul 2017 20:08:13 +0000 (-0500) Subject: xfs: check _alloc_read_agf buffer pointer before using X-Git-Tag: v4.13.0-rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d705962a19dc6b3e8db9530b6f7571ea0220682f;p=thirdparty%2Fxfsprogs-dev.git xfs: check _alloc_read_agf buffer pointer before using Source kernel commit: 10479e2dea83d4c421ad05dfc55d918aa8dfc0cd In some circumstances, _alloc_read_agf can return an error code of zero but also a null AGF buffer pointer. Check for this and jump out. Fixes-coverity-id: 1415250 Fixes-coverity-id: 1415320 Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 52ec20c74..3e0c81523 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1637,6 +1637,10 @@ xfs_refcount_recover_cow_leftovers( error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); if (error) goto out_trans; + if (!agbp) { + error = -ENOMEM; + goto out_trans; + } cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL); /* Find all the leftover CoW staging extents. */